瀏覽代碼

set handicap

Laserlicht 1 年之前
父節點
當前提交
dc54261574
共有 1 個文件被更改,包括 17 次插入5 次删除
  1. 17 5
      client/lobby/OptionsTab.cpp

+ 17 - 5
client/lobby/OptionsTab.cpp

@@ -835,20 +835,32 @@ OptionsTab::HandicapWindow::HandicapWindow()
 	}
 	
 	buttons.push_back(std::make_shared<CButton>(Point(159, 367), AnimationPath::builtin("IOKAY"), CButton::tooltip(), [this](){
-		//for (const auto& player : textinputs)
-		//	for (const auto& resource : player.second)
-	    //		continue;//todo
+		for (const auto& player : textinputs)
+		{
+			TResources resources = TResources();
+			int income = 100;
+			for (const auto& resource : player.second)
+			{
+				bool isIncome = resource.first.getNum() == EGameResID::COUNT - 1;
+				if(isIncome)
+					income = std::stoi(resource.second->getText());
+				else
+					resources[resource.first] = std::stoi(resource.second->getText());
+			}
+			CSH->setPlayerHandicap(player.first, PlayerSettings::Handicap{resources, income});
+		}
+	    		
 		close();
 	}, EShortcut::GLOBAL_RETURN));
 
 	updateShadow();
 	center();
 
-	TResources resourcesStart = TResources();
+	/*TResources resourcesStart = TResources();
 	resourcesStart[EGameResID::GOLD] = -500000;
 	int resourcesPercent = 120;
 	//CSH->setPlayerHandicap(s->color, PlayerSettings::Handicap{resourcesStart, resourcesPercent});
-	CSH->setPlayerHandicap((PlayerColor)0, PlayerSettings::Handicap{resourcesStart, resourcesPercent});
+	CSH->setPlayerHandicap((PlayerColor)0, PlayerSettings::Handicap{resourcesStart, resourcesPercent});*/
 }
 
 bool OptionsTab::HandicapWindow::receiveEvent(const Point & position, int eventType) const