this logic got cray cray

master
Bel LaPointe 2021-03-30 21:11:12 -05:00
parent a26c1a0043
commit 8c2510d837
2 changed files with 35 additions and 2 deletions

View File

@ -1,6 +1,7 @@
package entity
type Current struct {
Bet Currency
Turn int
Bet Currency
Turn int
Phase int
}

View File

@ -1,8 +1,40 @@
package rule
import "local/sandbox/cards/src/entity"
type Rule struct {
Ends []End
Phases []Phase
Hands []Hand
Deck Deck
}
func (rule Rule) ShouldEnd(game *entity.Game) bool {
if game == nil {
return false
}
if game.Current.Phase >= len(rule.Phases) {
return true
}
for _, end := range rule.Ends {
if _, ok := end(game); ok {
return true
}
}
return false
}
func (rule Rule) AdvancedPhase(game *entity.Game) bool {
if game == nil {
return false
}
if rule.ShouldEnd(game) {
game.Current.Phase = len(rule.Phases)
return true
}
if ok := rule.Phases[game.Current.Phase]; ok {
game.Current.Phase += 1
return true
}
return false
}