package game import ( "log" ) type Stack struct { gameState *State Actions []Action } func NewStack(s *State) *Stack { return &Stack{s, []Action{}} } func (s *Stack) IsEmpty() bool { return len(s.Actions) == 0 } func (s *Stack) Push(a Action) { s.Actions = append(s.Actions, a) } func (s *Stack) Pop() { l := len(s.Actions) if l == 0 { log.Fatalf("Can not pop from empty stack") } a := s.Actions[l-1] s.Actions = s.Actions[:l-1] a.Resolve(s.gameState) }