func (m *CreatureTurnMessage) ReadPacket(_packet pnet.IPacket) error {
	direction, err := _packet.ReadUint16()
	if err != nil {
		return err
	}
	m.Direction = int(direction)

	return nil
}
Esempio n. 2
0
func (m *DialogMessage) ReadPacket(_packet pnet.IPacket) error {
	answer, err := _packet.ReadUint32()
	if err != nil {
		return err
	}
	m.AnswerId = int(answer)

	return nil
}
func (m *QuestUpdateMessage) ReadPacket(_packet pnet.IPacket) (err error) {
	if m.Id, err = _packet.ReadInt64(); err != nil {
		return err
	}

	if m.Removed, err = _packet.ReadBool(); err != nil {
		return err
	}

	return nil
}
func (m *FriendUpdateMessage) ReadPacket(_packet pnet.IPacket) (err error) {
	if m.Name, err = _packet.ReadString(); err != nil {
		return
	}
	removed, errRem := _packet.ReadUint8()
	if errRem != nil {
		return errRem
	}
	m.Removed = int(removed)

	return nil
}
// WritePacket write the needed object data to a Packet and returns it
func (m *BattleEventMessage) WritePacket() pnet.IPacket {
	var packet pnet.IPacket = pnet.NewPacketExt(m.GetHeader())
	packet.AddUint32(m.EventType)

	switch m.EventType {
	case pnet.BATTLEEVENT_TEXT:
		packet = m.writeMessage(packet)
	case pnet.BATTLEEVENT_CHANGEPP:
		packet = m.writeChangePP(packet)
	case pnet.BATTLEEVENT_CHANGEHP:
		packet = m.writeChangeHP(packet)
	}

	return packet
}
Esempio n. 6
0
// ReadPacket reads all data from a packet and puts it in the object
func (m *WalkMessage) ReadPacket(_packet pnet.IPacket) (err error) {
	direction, err := _packet.ReadUint16()
	if err != nil {
		return
	}
	m.Direction = int(direction)

	sendMap, err := _packet.ReadUint16()
	if err != nil {
		return err
	}

	if sendMap == 1 {
		m.SendMap = true
	}

	return nil
}
func (m *BattleEventMessage) writeChangePP(_packet pnet.IPacket) pnet.IPacket {
	_packet.AddUint32(m.PokemonId)
	_packet.AddUint32(m.MoveSlotId)
	_packet.AddUint8(m.NewPP)

	return _packet
}
Esempio n. 8
0
func (m *ChatMessage) ReadPacket(_packet pnet.IPacket) (err error) {
	speaktype, err := _packet.ReadUint8()
	if err != nil {
		return
	}
	m.SpeakType = int(speaktype)

	channelId, err := _packet.ReadUint16()
	if err != nil {
		return
	}
	m.ChannelId = int(channelId)

	if m.Receiver, err = _packet.ReadString(); err != nil {
		return
	}
	if m.Text, err = _packet.ReadString(); err != nil {
		return
	}

	return nil
}
Esempio n. 9
0
// ReadPacket reads all data from a packet and puts it in the object
func (m *LoginMessage) ReadPacket(_packet pnet.IPacket) error {
	var err error
	if m.Username, err = _packet.ReadString(); err != nil {
		return err
	}
	if m.Password, err = _packet.ReadString(); err != nil {
		return err
	}
	clientVersion, err := _packet.ReadUint16()
	if err != nil {
		return err
	}
	m.ClientVersion = int(clientVersion)

	return nil
}
func (m *BattleEventMessage) writeMessage(_packet pnet.IPacket) pnet.IPacket {
	_packet.AddString(m.Text)

	return _packet
}
func (m *BattleEventMessage) writeChangeHP(_packet pnet.IPacket) pnet.IPacket {
	_packet.AddUint32(m.PokemonId)
	_packet.AddUint16(m.NewHP)

	return _packet
}