-
Notifications
You must be signed in to change notification settings - Fork 55
/
cmCards.go
39 lines (34 loc) · 1.04 KB
/
cmCards.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import (
"code.google.com/p/go.net/websocket"
"github.com/bitly/go-simplejson"
"log"
)
// return all cards of this player, in troop and off troop
func cmCardsGetHander(this *player, command string, param *simplejson.Json) {
rtnCode := 0
//TODO make this vaule globle for this player, PUSH_CARDS_ORDER will use it
var cardsArray []lvCardData
defer func() {
var rtnMsg interface{}
if 0 == rtnCode {
rtnMsg = cardsArray
} else {
rtnMsg, _ = errCodes[rtnCode]
}
rtnJson := responseJson(command, rtnCode, rtnMsg)
log.Println(rtnJson)
if err := websocket.Message.Send(this.ws, rtnJson); err != nil {
log.Printf("Send fail for cmCardsGetHander")
}
}()
//check for charInfo
if this.charID == 0 {
rtnCode = 6
return
}
for _, value := range this.character.cards {
card := gGameScript.getLvCard(value.ID, value.Level, value.Status)
cardsArray = append(cardsArray, *card)
}
}