def SpawnAnt(self, queens, map): for q in queens.keys(): point = Point.StringToPoint(q) + queens[q]._positionOrder if map.layerSolid.IsNone(point) and isinstance( map.layerFloor[point], Bread): map.layerSolid.Append( queens[q]._spawnType(map.layerSolid.GetNewId(), queens[q]._nameSpawn, queens[q]._team), point) map.layerFloor[point] = None queens[q]._order = Cfg.SLEEP queens[q]._positionOrder = None queens[q]._spawnType = None queens[q]._nameSpawn = ""
def FOVQueen(self, team, map): pos = Point.StringToPoint(self.GetQueenPosition(team)) FOVSolid = [] FOVFloor = [] for spawn in Queen.SPAWNS: if not (map.layerSolid[pos.x + spawn.x, pos.y + spawn.y] is None): FOVSolid.append(spawn) else: FOVSolid.append(None) if not (map.layerFloor[pos.x + spawn.x, pos.y + spawn.y] is None): FOVFloor.append(spawn) else: FOVFloor.append(None) return (FOVSolid, FOVFloor)
if __name__ == '__main__': from Sentiant.Model import MapManager, Ant from Sentiant.View import MainView import os from tkinter import Button class QueenTest(Queen): def newTurn(self): self.SpawnAnt("test", Ant, self.SPAWN1) def SpawnRess(map, position): map.layerFloor[position] = Bread(map.layerFloor.GetNewId()) os.chdir("..\\..\\") mapGen = MapManager() qM = QueensManager(3, ["1", "2", "3"], [QueenTest, QueenTest, QueenTest], mapGen) map = mapGen.Generate() view = MainView(map, size=(500, 500)) position = Point.StringToPoint(qM.GetQueenPosition()[0]) + Queen.SPAWN1 Button(view, command=lambda: SpawnRess(map, position)).pack() Button(view, text="NextTurn", command=lambda: qM.NextTurn(1, map)).pack() view.Run()