약 3 주 동안 프로그래밍 중이며이 civ 게임을 만들고 있습니다. 유일한 문제는 각 라운드 동안이며, civ에 대한 통계는 매 라운드마다 업데이트되지만 두 번째 라운드 이후에는 업데이트되지 않습니다. 기본적으로 내가 원하는 것은 각 라운드 후에 각 자원을 합산하여 인구와 금을 계산하지만, 첫 라운드 이후에는 일어나지 않습니다. 나는 수업을받지 못해서 처음으로 제대로 할 수 있기를 기대하지 마십시오. 그들은 문제가 아니라면, 변수까지 상단에C++ 변수가 While 루프에서 업데이트되지 않습니다.
int RoundTotal(int yg, int yk, int yf, int ys, int yr, int yfi,
int co, int rtp, int gtp, int ap, double tr, int yp, int dp,
int int yd, double fp) {
int YourGold = yg, YourStrength = ys, YourKnow = yk, YourFood = yf,
YourResource = yr, YourFields = yfi, YourPopulation = yp, YourDefense = yd;
int ResourceTradeProfit = rtp, GoldTradeProfit = gtp, DroughtProduction = dp;
int totals, count = co, ArcherPay = ap;
double taxrate = tr, FoodProduction = fp;
if (YourStrength<0) {
YourStrength = 0;
}
FoodProduction = (0.5*YourFields + 0.5*YourKnow - 0.02*YourPopulation)*DroughtProduction;
YourFood = YourFood + FoodProduction;
YourGold = YourGold + (taxrate/100)*YourPopulation;
YourGold -= (YourStrength/2);
YourGold -= YourKnow;
YourGold -= YourFood;
YourGold -= ArcherPay;
YourResource += ResourceTradeProfit;
YourGold += GoldTradeProfit;
YourPopulation = YourPopulation + YourFood*FoodProduction;
return totals, YourGold, YourKnow, YourFood, YourStrength,
YourResource, YourFields, count, ResourceTradeProfit,
GoldTradeProfit, ArcherPay, taxrate, YourPopulation,
DroughtProduction, FoodProduction;
무시 약어의 모든 : 여기
은 함수 내에서 각 라운드를 발생한다 업데이트에 대한 코드입니다.
당신이 반환 무엇을 기대합니까? – tkausl
당신의 함수는 단지 하나의'int'를 반환 할 뿐이므로이 함수의 호출 측에서 여러분은 하나의 값만을 얻습니다. 디자인 측면에서는이 데이터를 모두 포함하는 클래스를 만들어 클래스를 반환하거나 클래스에 업데이트 메서드를 추가 할 수 있습니다. – pstrjds
[comma operator] (http://en.cppreference.com/w/cpp/language/operator_other)와이 게시물 [여기] (https://stackoverflow.com/q/54142/)에 대해 읽어야합니다. 416574) – pstrjds