diff --git a/Main.py b/Main.py index 1a719b3..c4b5366 100644 --- a/Main.py +++ b/Main.py @@ -284,13 +284,16 @@ class uCommunicate: def gameLoop(self): while self.globalGameState == 1: for x in range(GameRealms.amount): + self.turnHolder = x + GameRealms.applyResourceIncome(x) if self.turnHolder != 0: self.turnHolder = GameRealms.players[x].id print(f"Turn being played by: {self.turnHolder}/{GameRealms.players[x].name}") self.expand_cccs(self.turnHolder) else: + GameRealms.updateDaywisePlayerResources(self.turnHolder, GameMap) while self.turnHolder == 0: - y = 1 + None def claimState(self): if GameMap.paintedTile and self.turnHolder == 0: @@ -300,6 +303,7 @@ class uCommunicate: if pt.Id in ip.borderTiles and ip.resources["villagers"] > 0: print(f"Claiming {pt.Id} for {ip.name}") GameMap.claimTileFor(pt.Id,ip) + ip.heldTiles.append(pt.Id) for tile in GameMap.findBorderTiles(pt.Id): ip.borderTiles.append(int(tile)) ip.resources["villagers"] -= 1 @@ -307,6 +311,7 @@ class uCommunicate: elif ip.resources["settlers"] > 0: print(f"Settling {pt.Id} for {ip.name}") GameMap.claimTileFor(pt.Id,ip) + ip.heldTiles.append(pt.Id) for tile in GameMap.findBorderTiles(pt.Id): ip.borderTiles.append(int(tile)) ip.resources["settlers"] -= 1 @@ -324,7 +329,7 @@ class uCommunicate: if tryTile != None: if not GameMap.tIsClaimed(tryTile): expandTile = tryTile - GameMap.claimTileFor(expandTile,GameRealms.getPlayer(f"{ccc}"),map) + GameMap.claimTileFor(expandTile,curPlayer,map) curPlayer.heldTiles.append(expandTile) else: while expandTile == None: diff --git a/Realms/RealmManager.py b/Realms/RealmManager.py index 3020caf..464de50 100644 --- a/Realms/RealmManager.py +++ b/Realms/RealmManager.py @@ -33,6 +33,30 @@ class RealmManager: return self.players[0] else: return self.players[int(detail)] + + def updateDaywisePlayerResources(self, id, MapMan): + print(f"\n\n\nUpdating DaywiseResourceGain for {id}\n\n") + p = self.players[id] + print(f"\nPrevious gains: {p.daywiseResourceGain}") + p.resetDailyGains() + print(f"HeldTiles Check: {p.heldTiles}") + for t in p.heldTiles: + tInfo = MapMan.tiles[str(t)] + for resource in tInfo.resources: + p.daywiseResourceGain[str(resource[1])] += resource[0] + print(f"\nNew gains: {p.daywiseResourceGain}") + + def applyResourceIncome(self, id): + print(f"Applying resource income for {id}") + p = self.players[id] + for r in p.daywiseResourceGain.keys(): + p.resources[str(r)] += p.daywiseResourceGain[str(r)] + if p.passiveResourceGain.keys(): + for r in p.passiveResourceGain.keys(): + p.resources[str(r)] += p.passiveResourceGain[str(r)] + + + class Player: @@ -47,6 +71,14 @@ class Player: "weapons": 0.0, "tools": 0.0, } + self.daywiseResourceGain = { + "wood": 0.0, + "stone": 0.0, + "food": 0.0, + "weapons": 0.0, + "tools": 0.0 + } + self.passiveResourceGain = {} self.id = id self.controller = controller self.heldTiles = [] @@ -54,4 +86,13 @@ class Player: colour = colour.split(",") print (colour) self.borderColour = (int(colour[0]),int(colour[1]),int(colour[2])) - self.name = name \ No newline at end of file + self.name = name + + def resetDailyGains(self): + self.daywiseResourceGain = { + "wood": 0.0, + "stone": 0.0, + "food": 0.0, + "weapons": 0.0, + "tools": 0.0 + } \ No newline at end of file diff --git a/Realms/__pycache__/RealmManager.cpython-312.pyc b/Realms/__pycache__/RealmManager.cpython-312.pyc index e3ad1ee..8192c88 100644 Binary files a/Realms/__pycache__/RealmManager.cpython-312.pyc and b/Realms/__pycache__/RealmManager.cpython-312.pyc differ