impl some hands

This commit is contained in:
Bel LaPointe
2021-03-17 08:16:47 -05:00
parent ec81bb24ad
commit 0c406e3163
5 changed files with 597 additions and 1 deletions

View File

@@ -1,5 +1,41 @@
package operation
import "local/sandbox/cards/src/entity"
import (
"encoding/json"
"errors"
"local/sandbox/cards/src/entity"
)
type Int func(*entity.Game, interface{}) int
var intStringified = map[string]Int{
"royalFlush": royalFlush,
"straightFlush": straightFlush,
"fourOfAKind": fourOfAKind,
"fullHouse": fullHouse,
"flush": flush,
"straight": straight,
"threeOfAKind": threeOfAKind,
"twoPair": twoPair,
"pair": pair,
"highCard": highCard,
}
func (foo *Int) UnmarshalJSON(b []byte) error {
var s string
if err := json.Unmarshal(b, &s); err != nil {
return err
}
return foo.FromString(s)
}
func (foo *Int) FromString(s string) error {
for k, v := range intStringified {
if k == s {
*foo = v
return nil
}
}
return errors.New("unknown int method " + s)
}