Skip to content

Commit

Permalink
Moved all the classical orders to the global orders package - they ar…
Browse files Browse the repository at this point in the history
…e, after all, used by all variants.
  • Loading branch information
zond committed Apr 5, 2018
1 parent fd31afd commit 81ca8be
Show file tree
Hide file tree
Showing 21 changed files with 30 additions and 29 deletions.
2 changes: 1 addition & 1 deletion gae/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package common
import (
"github.com/zond/godip/state"
"github.com/zond/godip/variants/classical"
"github.com/zond/godip/variants/classical/orders"
"github.com/zond/godip/orders"
"github.com/zond/godip/variants/common"

dip "github.com/zond/godip/common"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion variants/ancientmediterranean/ancientmediterranean_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"time"

"github.com/zond/godip/state"
"github.com/zond/godip/variants/classical/orders"
"github.com/zond/godip/orders"

dip "github.com/zond/godip/common"
cla "github.com/zond/godip/variants/classical/common"
Expand Down
6 changes: 3 additions & 3 deletions variants/classical/classical.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import (
"fmt"

"github.com/zond/godip/state"
"github.com/zond/godip/variants/classical/orders"
"github.com/zond/godip/variants/classical/start"
"github.com/zond/godip/variants/common"

dip "github.com/zond/godip/common"
cla "github.com/zond/godip/variants/classical/common"
ord "github.com/zond/godip/variants/classical/orders"
)

var ClassicalVariant = common.Variant{
Expand All @@ -20,7 +20,7 @@ var ClassicalVariant = common.Variant{
result = Blank(Phase(1900, cla.Fall, cla.Adjustment))
return
},
Parser: orders.ClassicalParser,
Parser: ord.ClassicalParser,
Graph: func() dip.Graph { return start.Graph() },
Phase: Phase,
Nations: cla.Nations,
Expand Down Expand Up @@ -51,7 +51,7 @@ func Blank(phase dip.Phase) *state.State {
}

func Start() (result *state.State, err error) {
result = state.New(start.Graph(), &phase{1901, cla.Spring, cla.Movement, orders.ClassicalParser}, BackupRule)
result = state.New(start.Graph(), &phase{1901, cla.Spring, cla.Movement, ord.ClassicalParser}, BackupRule)
if err = result.SetUnits(start.Units()); err != nil {
return
}
Expand Down
5 changes: 3 additions & 2 deletions variants/classical/classical_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import (
"time"

"github.com/zond/godip/datc"
"github.com/zond/godip/orders"
"github.com/zond/godip/state"
"github.com/zond/godip/variants/classical/orders"
"github.com/zond/godip/variants/classical/start"

dip "github.com/zond/godip/common"
cla "github.com/zond/godip/variants/classical/common"
ord "github.com/zond/godip/variants/classical/orders"
tst "github.com/zond/godip/variants/testing"
)

Expand Down Expand Up @@ -420,7 +421,7 @@ func TestBULOptions(t *testing.T) {
// Test that por M spa supported by mid works in
// https://diplicity-engine.appspot.com/Game/ahJzfmRpcGxpY2l0eS1lbmdpbmVyEQsSBEdhbWUYgICAgOr0mgoM/Phase/12/Map
func TestMIDPORSPASupportOptions(t *testing.T) {
judge := state.New(start.Graph(), &phase{1903, cla.Fall, cla.Movement, orders.ClassicalParser}, BackupRule)
judge := state.New(start.Graph(), &phase{1903, cla.Fall, cla.Movement, ord.ClassicalParser}, BackupRule)
if err := judge.SetUnits(start.Units()); err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion variants/classical/datc.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"time"

cla "github.com/zond/godip/variants/classical/common"
"github.com/zond/godip/variants/classical/orders"
"github.com/zond/godip/orders"
"github.com/zond/godip/variants/classical/start"
dip "github.com/zond/godip/common"
)
Expand Down
14 changes: 7 additions & 7 deletions variants/classical/orders/orders.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
)

var ClassicalParser = orders.NewParser([]dip.Order{
BuildOrder,
ConvoyOrder,
DisbandOrder,
HoldOrder,
MoveOrder,
MoveViaConvoyOrder,
SupportOrder,
orders.BuildOrder,
orders.ConvoyOrder,
orders.DisbandOrder,
orders.HoldOrder,
orders.MoveOrder,
orders.MoveViaConvoyOrder,
orders.SupportOrder,
})
12 changes: 6 additions & 6 deletions variants/classical/phase.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,36 @@ import (
"sort"
"strings"

"github.com/zond/godip/variants/classical/orders"
"github.com/zond/godip/orders"

dip "github.com/zond/godip/common"
ord "github.com/zond/godip/orders"
cla "github.com/zond/godip/variants/classical/common"
ord "github.com/zond/godip/variants/classical/orders"
)

func PhaseGenerator(parser ord.Parser) func(int, dip.Season, dip.PhaseType) dip.Phase {
func PhaseGenerator(parser orders.Parser) func(int, dip.Season, dip.PhaseType) dip.Phase {
return func(year int, season dip.Season, typ dip.PhaseType) dip.Phase {
return &phase{year, season, typ, parser}
}
}

func Phase(year int, season dip.Season, typ dip.PhaseType) dip.Phase {
return PhaseGenerator(orders.ClassicalParser)(year, season, typ)
return PhaseGenerator(ord.ClassicalParser)(year, season, typ)
}

type phase struct {
year int
season dip.Season
typ dip.PhaseType
parser ord.Parser
parser orders.Parser
}

func (self *phase) String() string {
return fmt.Sprintf("%s %d, %s", self.season, self.year, self.typ)
}

func (self *phase) Options(s dip.Validator, nation dip.Nation) (result dip.Options) {
return s.Options(orders.ClassicalParser.Orders(), nation)
return s.Options(ord.ClassicalParser.Orders(), nation)
}

func shortestDistance(s dip.State, src dip.Province, dst []dip.Province) (result int, err error) {
Expand Down
2 changes: 1 addition & 1 deletion variants/coldwar/coldwar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/zond/godip/state"
"github.com/zond/godip/variants/classical"
"github.com/zond/godip/variants/classical/orders"
"github.com/zond/godip/orders"

dip "github.com/zond/godip/common"
cla "github.com/zond/godip/variants/classical/common"
Expand Down
2 changes: 1 addition & 1 deletion variants/hundred/hundred.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/zond/godip/graph"
"github.com/zond/godip/state"
"github.com/zond/godip/variants/classical"
"github.com/zond/godip/variants/classical/orders"
"github.com/zond/godip/orders"
"github.com/zond/godip/variants/common"

dip "github.com/zond/godip/common"
Expand Down
2 changes: 1 addition & 1 deletion variants/hundred/hundred_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/zond/godip/state"
"github.com/zond/godip/variants/classical"
"github.com/zond/godip/variants/classical/orders"
"github.com/zond/godip/orders"

dip "github.com/zond/godip/common"
cla "github.com/zond/godip/variants/classical/common"
Expand Down
2 changes: 1 addition & 1 deletion variants/hundred/hundredphase.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"

"github.com/zond/godip/variants/classical"
"github.com/zond/godip/variants/classical/orders"
"github.com/zond/godip/orders"

dip "github.com/zond/godip/common"
cla "github.com/zond/godip/variants/classical/common"
Expand Down
2 changes: 1 addition & 1 deletion variants/pure/pure.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/zond/godip/graph"
"github.com/zond/godip/state"
"github.com/zond/godip/variants/classical"
"github.com/zond/godip/variants/classical/orders"
"github.com/zond/godip/orders"
"github.com/zond/godip/variants/common"

dip "github.com/zond/godip/common"
Expand Down
2 changes: 1 addition & 1 deletion variants/testing/games_testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"time"

"github.com/zond/godip/state"
"github.com/zond/godip/variants/classical/orders"
"github.com/zond/godip/orders"
"github.com/zond/godip/variants/common"

dip "github.com/zond/godip/common"
Expand Down
2 changes: 1 addition & 1 deletion variants/testing/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"testing"

"github.com/zond/godip/state"
"github.com/zond/godip/variants/classical/orders"
"github.com/zond/godip/orders"

dip "github.com/zond/godip/common"
cla "github.com/zond/godip/variants/classical/common"
Expand Down
2 changes: 1 addition & 1 deletion variants/youngstownredux/youngstownredux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/zond/godip/state"
"github.com/zond/godip/variants/classical"
"github.com/zond/godip/variants/classical/orders"
"github.com/zond/godip/orders"

dip "github.com/zond/godip/common"
cla "github.com/zond/godip/variants/classical/common"
Expand Down

0 comments on commit 81ca8be

Please sign in to comment.