Commit 27/05-24

Computer functionality! 6 players can now start a round, one is the human player and 5 are computer players. They can't really play, they just randomly select tiles and claim them.
This commit is contained in:
Hannah-Dagemark 2024-05-27 14:31:11 +02:00
commit 081a8a948a
6 changed files with 127 additions and 19 deletions

View file

@ -11,10 +11,15 @@ class RealmManager:
print (self.compnames)
self.compnames = self.compnames.split("\n")
temptext.close()
temptext = open("./Realms/valid_border_colours.txt", "r")
self.colournames = temptext.read()
print (self.colournames)
self.colournames = self.colournames.split("\n")
temptext.close()
for x in range(self.amount):
if x == 0:
self.players[0] = Player("p1")
self.players[x] = Player("c", x, self.compnames)
self.players[0] = Player("p1", self.colournames)
self.players[x] = Player("c", self.colournames, x, self.compnames)
for x in self.players:
p = self.players[x]
print(f"Player {p.id}/{p.name} with colour {p.borderColour}")
@ -23,14 +28,18 @@ class RealmManager:
if detail == "p1":
return self.players[0]
else:
print("oopsie")
return self.players[int(detail)]
class Player:
def __init__(self, controller, id=0, names=None):
def __init__(self, controller, colour, id=0, names=None,):
self.id = id
self.controller = controller
self.borderColour = (random.randint(10,240),random.randint(10,240),random.randint(10,240))
self.heldTiles = []
colour = colour[random.randint(0,len(colour)-1)]
colour = colour.split(",")
print (colour)
self.borderColour = (int(colour[0]),int(colour[1]),int(colour[2]))
if controller == "c":
self.name = names[random.randint(0,len(names)-1)]