Last active
March 19, 2024 20:08
Revisions
-
kamyker revised this gist
Mar 19, 2024 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -65,6 +65,12 @@ player_stats_managerr := class(): ClonePlayerStatsTable<constructor>(PlayerStatsTable) Score := ScoreStat.GetUpdated(Score) # MakePlayerStatsTable<constructor>(OldTable:player_stats_table)<transacts> := player_stats_table: # Version := OldTable.Version # Score := OldTable.Score # Wins := OldTable.Wins # Losses := OldTable.Losses # # player_stat := class<final><persistable>: # CurrentValue:int = 0 # HighestValue:int = 0 -
kamyker revised this gist
Mar 19, 2024 . 1 changed file with 77 additions and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -63,4 +63,80 @@ player_stats_managerr := class(): set PlayerStatsMap[player[Agent]] = player_stats_table: ClonePlayerStatsTable<constructor>(PlayerStatsTable) Score := ScoreStat.GetUpdated(Score) # player_stat := class<final><persistable>: # CurrentValue:int = 0 # HighestValue:int = 0 # SetHighestValue(NewValue:int)<transacts>:int= # if (NewValue > HighestValue): # NewValue # else: # HighestValue # MakeUpdatedPlayerStat<constructor>(OldStats:player_stat, NewValue:int)<transacts> := player_stat: # CurrentValue := NewValue # HighestValue := OldStats.SetHighestValue(NewValue) # stat_type := class<computes><unique><abstract>: # DebugString():string # StatType := module: # score_stat<public> := class<computes><unique>(stat_type): # DebugString<override>():string = "Score" # win_stat<public> := class<computes><unique>(stat_type): # DebugString<override>():string = "Win" # loss_stat<public> := class<computes><unique>(stat_type): # DebugString<override>():string = "Loss" # Score<public>:score_stat = score_stat{} # Win<public>:win_stat = win_stat{} # Loss<public>:loss_stat = loss_stat{} # player_stats_manager := class(): # GetPlayerStats(Agent:agent)<decides><transacts>:player_stats_table= # var PlayerStats:player_stats_table = player_stats_table{} # if: # Player := player[Agent] # PlayerStatsTable := PlayerStatsMap[Player] # set PlayerStats = MakePlayerStatsTable(PlayerStatsTable) # PlayerStats # InitializeAllPlayers(Players:[]player):void = # for (Player : Players): # InitializePlayer(Player) # InitializePlayer(Player:player):void= # if: # not PlayerStatsMap[Player] # set PlayerStatsMap[Player] = player_stats_table{} # RecordPlayerStat(Agent:agent, Stat:stat_type, ?Score:int = 0):void= # if: # Player := player[Agent] # PlayerStatsTable := PlayerStatsMap[Player] # if(Stat = StatType.Score): # ScoreStat := PlayerStatsTable.Score # set PlayerStatsMap[Player] = player_stats_table: # MakePlayerStatsTable<constructor>(PlayerStatsTable) # Score := MakeUpdatedPlayerStat(ScoreStat, Score) # else if(Stat = StatType.Win): # WinsStat := PlayerStatsTable.Wins # set PlayerStatsMap[Player] = player_stats_table: # MakePlayerStatsTable<constructor>(PlayerStatsTable) # Wins := MakeUpdatedPlayerStat(WinsStat, WinsStat.CurrentValue+1) # else if(Stat = StatType.Loss): # LossesStat := PlayerStatsTable.Losses # set PlayerStatsMap[Player] = player_stats_table: # MakePlayerStatsTable<constructor>(PlayerStatsTable) # Losses := MakeUpdatedPlayerStat(LossesStat, LossesStat.CurrentValue+1) -
kamyker revised this gist
Mar 19, 2024 . No changes.There are no files selected for viewing
-
kamyker created this gist
Mar 19, 2024 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,66 @@ var PlayerStatsMap:weak_map(player, player_stats_table) = map{} player_stats_table := class<final><persistable>: Version:int = 0 Score:player_stat = player_stat{} Wins:player_stat = player_stat{} Losses:player_stat = player_stat{} ClonePlayerStatsTable<constructor>(OldTable:player_stats_table)<transacts> := player_stats_table: Version := OldTable.Version Score := OldTable.Score Wins := OldTable.Wins Losses := OldTable.Losses player_stat := class<final><persistable>: CurrentValue:int = 0 HighestValue:int = 0 GetUpdated(NewValue:int)<transacts>:player_stat= player_stat: CurrentValue := NewValue HighestValue := if. NewValue > HighestValue then NewValue else HighestValue player_stats_managerr := class(): GetPlayerStats(Agent:agent)<decides><transacts>:player_stats_table= Player := player[Agent] PlayerStatsMap[Player] InitializeAllPlayers(Players:[]player):void = for (Player : Players): InitializePlayer(Player) InitializePlayer(Player:player):void= if: not PlayerStatsMap[Player] set PlayerStatsMap[Player] = player_stats_table{} IncreaseWins(Agent:agent):void= if: PlayerStatsTable := GetPlayerStats[Agent] WinStat := PlayerStatsTable.Wins set PlayerStatsMap[player[Agent]] = player_stats_table: ClonePlayerStatsTable<constructor>(PlayerStatsTable) Wins := WinStat.GetUpdated(WinStat.CurrentValue+1) IncreaseLosses(Agent:agent):void= if: PlayerStatsTable := GetPlayerStats[Agent] LossesStat := PlayerStatsTable.Losses set PlayerStatsMap[player[Agent]] = player_stats_table: ClonePlayerStatsTable<constructor>(PlayerStatsTable) Losses := LossesStat.GetUpdated(LossesStat.CurrentValue+1) RecordScore(Agent:agent, Score:int):void= if: PlayerStatsTable := GetPlayerStats[Agent] ScoreStat := PlayerStatsTable.Score set PlayerStatsMap[player[Agent]] = player_stats_table: ClonePlayerStatsTable<constructor>(PlayerStatsTable) Score := ScoreStat.GetUpdated(Score)