Skip to content

Commit

Permalink
[Refactor] Rename package to remove useless parts
Browse files Browse the repository at this point in the history
  • Loading branch information
CornWorld committed Feb 7, 2024
1 parent 094d1ef commit 7493155
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/server/game/block/base_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ func (*BaseBlock) MoveFrom(_ uint16) uint16 {
return 0
}

func (*BaseBlock) MoveTo(BlockVal) Block {
func (*BaseBlock) MoveTo(Val) Block {
return nil
}
2 changes: 1 addition & 1 deletion packages/server/game/block/base_building.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions packages/server/game/block/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion packages/server/game/block/block_blank.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion packages/server/game/block/block_king.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/server/game/block/block_soldier.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/server/game/map/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions packages/server/game/map/map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion packages/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 7493155

Please sign in to comment.