func NewTeamPokeFromPacket(_packet *pnet.QTPacket) *TeamPoke { teamPoke := TeamPoke{} teamPoke.UID = NewUniqueIdFromPacket(_packet) teamPoke.Nick = _packet.ReadString() teamPoke.Item = int(_packet.ReadUint16()) teamPoke.Ability = int(_packet.ReadUint16()) teamPoke.Nature = int(_packet.ReadUint8()) teamPoke.Gender = int(_packet.ReadUint8()) // teamPoke.Gen = (int)_packet.ReadByte() teamPoke.Shiny = _packet.ReadBool() teamPoke.Happiness = int(_packet.ReadUint8()) teamPoke.Level = int(_packet.ReadUint8()) teamPoke.Moves = make([]int, 4) for i := 0; i < 4; i++ { teamPoke.Moves[i] = int(_packet.ReadUint32()) } teamPoke.DVs = make([]int, 6) for i := 0; i < 6; i++ { teamPoke.DVs[i] = int(_packet.ReadUint8()) } teamPoke.EVs = make([]int, 6) for i := 0; i < 6; i++ { teamPoke.EVs[i] = int(_packet.ReadUint8()) } return &teamPoke }
func (c *POClient) battleMessage(_packet *pnet.QTPacket) { if c.battle != nil { _packet.ReadUint32() // Supporting only one battle, unneeded _packet.ReadUint32() // Discard the size, unneeded c.battle.ReceiveCommand(_packet) } }
func (c *POClient) engageBattle(_packet *pnet.QTPacket) { c.bID = int(_packet.ReadUint32()) pID1 := int(_packet.ReadUint32()) pID2 := int(_packet.ReadUint32()) if pID1 == 0 { // This is us! battleConf := NewBattleConfFromPacket(_packet) // Start the battle c.battle = NewBattle(c, battleConf, _packet, c.players[battleConf.GetId(0)], c.players[battleConf.GetId(1)], c.mePlayer.Id, c.bID) fmt.Printf("Battle between %s and %s started!\n", c.mePlayer.Nick, c.players[pID2].Nick) } }
func NewShallowBattlePokeFromPacket(_packet *pnet.QTPacket, _isMe bool) *ShallowBattlePoke { shallowPoke := ShallowBattlePoke{Types: make([]int, 2)} shallowPoke.UID = NewUniqueIdFromPacket(_packet) shallowPoke.RNick = _packet.ReadString() shallowPoke.Nick = shallowPoke.RNick if !_isMe { shallowPoke.Nick = "the foe's " + shallowPoke.Nick shallowPoke.getName() shallowPoke.getTypes() } shallowPoke.LifePercent = int(_packet.ReadUint8()) shallowPoke.fullStatus = _packet.ReadUint32() shallowPoke.Gender = int(_packet.ReadUint8()) shallowPoke.Shiny = _packet.ReadBool() shallowPoke.Level = int(_packet.ReadUint32()) return &shallowPoke }
func (b *Battle) receivedBeginTurn(_packet *pnet.QTPacket) { turn := _packet.ReadUint32() b.WriteToHist(fmt.Sprintf("Start of turn %d!\n", turn)) }