mirror of
https://github.com/genxium/DelayNoMore
synced 2025-10-09 08:36:52 +00:00
Initial commit.
This commit is contained in:
9
battle_srv/test_cases/Makefile
Normal file
9
battle_srv/test_cases/Makefile
Normal file
@@ -0,0 +1,9 @@
|
||||
PROJECTNAME=tests
|
||||
ROOT_DIR=$(shell pwd)
|
||||
all: help
|
||||
|
||||
run-test: build
|
||||
GOPATH=$(GOPATH):$(ROOT_DIR)/.. ServerEnv=TEST ./$(PROJECTNAME)
|
||||
|
||||
build:
|
||||
go build -o $(ROOT_DIR)/$(PROJECTNAME) ./tests.go
|
79
battle_srv/test_cases/tests.go
Normal file
79
battle_srv/test_cases/tests.go
Normal file
@@ -0,0 +1,79 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
. "server/common"
|
||||
"server/models"
|
||||
)
|
||||
|
||||
var relativePath string
|
||||
|
||||
func loadTMX(fp string, pTmxMapIns *models.TmxMap) {
|
||||
if !filepath.IsAbs(fp) {
|
||||
panic("Tmx filepath must be absolute!")
|
||||
}
|
||||
|
||||
byteArr, err := ioutil.ReadFile(fp)
|
||||
ErrFatal(err)
|
||||
models.DeserializeToTmxMapIns(byteArr, pTmxMapIns)
|
||||
for _, info := range pTmxMapIns.TreasuresInfo {
|
||||
fmt.Printf("treasuresInfo: %v\n", info)
|
||||
}
|
||||
for _, info := range pTmxMapIns.HighTreasuresInfo {
|
||||
fmt.Printf("treasuresInfo: %v\n", info)
|
||||
}
|
||||
}
|
||||
|
||||
func loadTSX(fp string, pTsxIns *models.Tsx) {
|
||||
if !filepath.IsAbs(fp) {
|
||||
panic("Tmx filepath must be absolute!")
|
||||
}
|
||||
|
||||
byteArr, err := ioutil.ReadFile(fp)
|
||||
ErrFatal(err)
|
||||
models.DeserializeToTsxIns(byteArr, pTsxIns)
|
||||
for _, Pos := range pTsxIns.TrapPolyLineList {
|
||||
fmt.Printf("%v\n", Pos)
|
||||
}
|
||||
}
|
||||
|
||||
func getTMXInfo() {
|
||||
relativePath = "../frontend/assets/resources/map/treasurehunter.tmx"
|
||||
execPath, err := os.Executable()
|
||||
ErrFatal(err)
|
||||
|
||||
pwd, err := os.Getwd()
|
||||
ErrFatal(err)
|
||||
|
||||
fmt.Printf("execPath = %v, pwd = %s, returning...\n", execPath, pwd)
|
||||
|
||||
tmxMapIns := models.TmxMap{}
|
||||
pTmxMapIns := &tmxMapIns
|
||||
fp := filepath.Join(pwd, relativePath)
|
||||
fmt.Printf("fp == %v\n", fp)
|
||||
loadTMX(fp, pTmxMapIns)
|
||||
}
|
||||
|
||||
func getTSXInfo() {
|
||||
|
||||
relativePath = "../frontend/assets/resources/map/tile_1.tsx"
|
||||
execPath, err := os.Executable()
|
||||
ErrFatal(err)
|
||||
|
||||
pwd, err := os.Getwd()
|
||||
ErrFatal(err)
|
||||
|
||||
fmt.Printf("execPath = %v, pwd = %s, returning...\n", execPath, pwd)
|
||||
tsxIns := models.Tsx{}
|
||||
pTsxIns := &tsxIns
|
||||
fp := filepath.Join(pwd, relativePath)
|
||||
fmt.Printf("fp == %v\n", fp)
|
||||
loadTSX(fp, pTsxIns)
|
||||
}
|
||||
|
||||
func main() {
|
||||
getTSXInfo()
|
||||
}
|
Reference in New Issue
Block a user