public void ProduceOne(ResourceBank tempRB) { if (tempRB.TokenInBank > 0) { Token++; tempRB.TokenInBank--; } }
public void Produce(ResourceBank tempRB) { if (tempRB.TokenInBank > 0) { int actualProductionAmount = tempRB.TokenInBank > Unit ? Unit : tempRB.TokenInBank; Token += actualProductionAmount; tempRB.TokenInBank -= actualProductionAmount; } }
public Player(string name, int playerindex, int myindex) { MyName = name; Science = 1; Strength = 1; timer.Tick += timer_Tick; timer.Interval = new TimeSpan(0, 0, tempTimer); playerIndex = playerindex; myIndex = myindex; rBank = new ResourceBank(playerindex); }
public int Consume(int num, ResourceBank tempRB) { int temp = num; if (Token > 0) { int actual_FTBC, expected_FTBC; expected_FTBC = num % productValue == 0 ? num / productValue : num / productValue + 1; actual_FTBC = Token >= expected_FTBC ? expected_FTBC : Token; Token -= actual_FTBC; temp = num - productValue * actual_FTBC; tempRB.TokenInBank += actual_FTBC; } return(temp); }
public int Replace(int num, ResourceBank rBank) { int temp = num; if (num >= productValue) { int expectedToken = num / productValue; temp = num - expectedToken * productValue; if (rBank.TokenInBank < expectedToken) { expectedToken = rBank.TokenInBank; temp = 0; } Token += expectedToken; rBank.TokenInBank -= expectedToken; } return(temp); }