resumed work; adjusted player string generation

This commit is contained in:
Sakimori 2022-07-30 19:26:33 -07:00
parent 8622dc5b1e
commit 3ceaf97f23
4 changed files with 26 additions and 7 deletions

View file

@ -11,7 +11,7 @@
<OutputPath>.</OutputPath>
<Name>SimHoc</Name>
<RootNamespace>SimHoc</RootNamespace>
<InterpreterId>MSBuild|Hockey|$(MSBuildProjectFullPath)</InterpreterId>
<InterpreterId>MSBuild|hockey10|$(MSBuildProjectFullPath)</InterpreterId>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
@ -50,6 +50,15 @@
<Compile Include="SimHoc.py" />
</ItemGroup>
<ItemGroup>
<Interpreter Include=".env\hockey10\">
<Id>hockey10</Id>
<Version>3.10</Version>
<Description>hockey10 (Python 3.10 (64-bit))</Description>
<InterpreterPath>Scripts\python.exe</InterpreterPath>
<WindowsInterpreterPath>Scripts\pythonw.exe</WindowsInterpreterPath>
<PathEnvironmentVariable>PYTHONPATH</PathEnvironmentVariable>
<Architecture>X64</Architecture>
</Interpreter>
<Interpreter Include="Hockey\">
<Id>Hockey</Id>
<Version>3.8</Version>

View file

@ -123,7 +123,8 @@ class Game(object):
self.positionInPossession = SkaterPosition(random.sample([0, 1, 1, 3, 3, 4],1)[0]) #wingers are less likely to recieve the faceoff than defensemen
self.playStopped = False
winningPlayer = self.skatersInPossession()[SkaterPosition.C.value]
eventString = f"{self.clockToMinutesSeconds()} - {self.teamInPossession.shortname} {str(winningPlayer)} wins faceoff."
receivingPlayer = self.skatersInPossession()[self.positionInPossession.value]
eventString = f"{self.clockToMinutesSeconds()} - {self.teamInPossession.shortname} {str(winningPlayer)} wins faceoff to {str(receivingPlayer)}"
self.eventLog.append(eventString)
self.eventLogVerbose.append(eventString)
self.clock -= random.randint(2,5)
@ -132,7 +133,7 @@ class Game(object):
def saveMadeStop(self, shootingPlayer, shotType):
"""Stops play due to a save made by a goalie, and sets the faceoff dot to be used."""
self.playStopped = True
eventText = f"{self.clockToMinutesSeconds()} - {str(self.defendingGoalie)} saves shot from {str(shootingPlayer), stops play.}"
eventText = f"{self.clockToMinutesSeconds()} - {str(self.defendingGoalie)} saves shot from {str(shootingPlayer)}, stops play."
self.eventLog.append(eventText)
self.eventLogVerbose.append(eventText)
options = [FaceoffDot.AwayZoneLeft, FaceoffDot.AwayZoneRight] if self.homeAttacking() else [FaceoffDot.HomeZoneLeft, FaceoffDot.HomeZoneRight]

View file

@ -127,4 +127,4 @@ class TestGame(object):
self.Game.playStopped = True
foResult = self.Game.event() #this doesnt return anything but it's nice to know what it's for I guess
lines = self.Game.eventLogOut()
pass
print(lines)

View file

@ -10,7 +10,7 @@ class Player(object):
def __init__(self, name:str, number:int=0):
if name is None:
self.attributes = []
elif len(name) > 30:
elif len(name) > 20:
raise CreationError("Player name too long.")
elif number < 0 or number > 99:
raise CreationError("Player number not valid.")
@ -18,6 +18,8 @@ class Player(object):
self.name = name
self.attributes = self.loadAttributes()
self.number = number
scoutLevel = 0 #how well scouted opposing team is; not changing
confidenceStage = 0 #how well the player can judge enemy skill; builds over game
def loadAttributes(self):
"""Generates attributes based on name, or loads from database if present."""
@ -62,10 +64,16 @@ class Player(object):
def initials(self):
names = self.name.split()
outString = ""
if len(names) >= 2:
for name in names:
outString += f"{name[0]}."
else:
outString = f"{self.name[:3]}."
return outString
def predictOpposingAction(self, opposingSkater):
raise NotImplementedError()
def chooseAtkAction(self):
raise NotImplementedError()
@ -81,6 +89,7 @@ class Goalie(Player):
"""A hockey player that *is* a goalie."""
pass
class AtkAction(Enum):
SkateB = 0
SkateF = 1