diff --git a/packages/server/game/block/base_block.go b/packages/server/game/block/base_block.go index f27784a..798ee95 100644 --- a/packages/server/game/block/base_block.go +++ b/packages/server/game/block/base_block.go @@ -36,6 +36,6 @@ func (*BaseBlock) MoveFrom(_ uint16) uint16 { return 0 } -func (*BaseBlock) MoveTo(BlockVal) Block { +func (*BaseBlock) MoveTo(Val) Block { return nil } diff --git a/packages/server/game/block/base_building.go b/packages/server/game/block/base_building.go index fa7ba2d..d77f8f0 100644 --- a/packages/server/game/block/base_building.go +++ b/packages/server/game/block/base_building.go @@ -32,7 +32,7 @@ func (block *BaseBuilding) MoveFrom(number uint16) uint16 { return ret } -func (block *BaseBuilding) MoveTo(info BlockVal) Block { +func (block *BaseBuilding) MoveTo(info Val) Block { if block.ownerId != info.OwnerId { if block.number < info.Number { block.ownerId = info.OwnerId diff --git a/packages/server/game/block/block.go b/packages/server/game/block/block.go index 2bae81c..4b5cf19 100644 --- a/packages/server/game/block/block.go +++ b/packages/server/game/block/block.go @@ -25,14 +25,14 @@ type Block interface { GetMoveStatus() MoveStatus MoveFrom(number uint16) uint16 // MoveTo Ret: a new block to replace this place - MoveTo(BlockVal) Block + MoveTo(Val) Block Meta() BlockMeta } type Position struct{ X, Y uint8 } -type BlockVal struct { +type Val struct { Number uint16 OwnerId uint16 } diff --git a/packages/server/game/block/block_blank.go b/packages/server/game/block/block_blank.go index 7523c61..d37abf6 100644 --- a/packages/server/game/block/block_blank.go +++ b/packages/server/game/block/block_blank.go @@ -29,6 +29,6 @@ func toBlockBlank(Block) Block { return Block(&Blank{}) } -func (b *Blank) MoveTo(BlockVal) Block { +func (b *Blank) MoveTo(Val) Block { return toBlockSoldier(b) } diff --git a/packages/server/game/block/block_king.go b/packages/server/game/block/block_king.go index 4a8785a..f723c8d 100644 --- a/packages/server/game/block/block_king.go +++ b/packages/server/game/block/block_king.go @@ -34,7 +34,7 @@ func (*King) Meta() BlockMeta { return KingMeta } -func (block *King) MoveTo(info BlockVal) Block { +func (block *King) MoveTo(info Val) Block { if !block.IsDied() { block.BaseBuilding.MoveTo(info) } diff --git a/packages/server/game/block/block_soldier.go b/packages/server/game/block/block_soldier.go index a78744c..d3939d5 100644 --- a/packages/server/game/block/block_soldier.go +++ b/packages/server/game/block/block_soldier.go @@ -54,7 +54,7 @@ func (block *Soldier) MoveFrom(number uint16) uint16 { return ret } -func (block *Soldier) MoveTo(info BlockVal) Block { +func (block *Soldier) MoveTo(info Val) Block { if block.ownerId != info.OwnerId { if block.number < info.Number { block.ownerId = info.OwnerId diff --git a/packages/server/game/map/map.go b/packages/server/game/map/map.go index b172390..6600b95 100644 --- a/packages/server/game/map/map.go +++ b/packages/server/game/map/map.go @@ -161,7 +161,7 @@ func (p *Map) Move(inst instruction.Move) bool { var toBlockNew block.Block hasMovedNum := thisBlock.MoveFrom(inst.Number) - toBlockNew = toBlock.MoveTo(block.BlockVal{Number: hasMovedNum, OwnerId: thisBlock.OwnerId()}) + toBlockNew = toBlock.MoveTo(block.Val{Number: hasMovedNum, OwnerId: thisBlock.OwnerId()}) if toBlockNew != nil { p.SetBlock(newPosition, toBlockNew) } diff --git a/packages/server/game/map/map_test.go b/packages/server/game/map/map_test.go index 90aa00d..e5a9243 100644 --- a/packages/server/game/map/map_test.go +++ b/packages/server/game/map/map_test.go @@ -114,14 +114,14 @@ func TestConvJsonStrMap(t *testing.T) { }, } for _, tt := range tests { - t.Run("JsonStrToMap: "+tt.name, func(t *testing.T) { + t.Run("JsonStrToMap:"+tt.name, func(t *testing.T) { if got := JsonStrToMap(tt.args.jsonStr); !reflect.DeepEqual(got, tt.want) { t.Errorf("JsonStrToMap() = \n%s, want \n%s", spew.Sdump(got), spew.Sdump(tt.want)) } }) } for _, tt := range tests { - t.Run("MapToJsonStr: "+tt.name, func(t *testing.T) { + t.Run("MapToJsonStr:"+tt.name, func(t *testing.T) { got := MapToJsonStr(tt.want) var j1, j2 *Map j1 = JsonStrToMap(got) diff --git a/packages/server/main.go b/packages/server/main.go index cef78c3..ed66767 100644 --- a/packages/server/main.go +++ b/packages/server/main.go @@ -10,7 +10,7 @@ import ( "server/game" _ "server/game/block" "server/game/instruction" - judge_pool "server/game/judge_pool" + "server/game/judge_pool" "server/utils/pkg/data_source/local" db "server/utils/pkg/pg" "time"