func (b *Battle) receivedAbilityMessage(_packet *pnet.QTPacket, _player int) { ab := int(_packet.ReadUint16()) part := int(_packet.ReadUint8()) msgType := int(_packet.ReadUint8()) foe := int(_packet.ReadUint8()) other := int(_packet.ReadUint16()) s := pokemon.GetInstance().GetAbilityMessage((ab + 1), part) if other != -1 && strings.Contains(s, "%st") { s = strings.Replace(s, "%st", puh.GetStatById(other), 0) } s = strings.Replace(s, "%s", b.currentPoke(_player).Nick, 0) if msgType != -1 { s = strings.Replace(s, "%t", puh.GetTypeValueById(msgType), 0) } if foe != -1 { s = strings.Replace(s, "%f", b.currentPoke(foe).Nick, 0) } if other != -1 { if strings.Contains(s, "%m") { s = strings.Replace(s, "%m", pokemon.GetInstance().GetMoveNameById(other), 0) } if strings.Contains(s, "%i") { s = strings.Replace(s, "%i", pokemon.GetInstance().GetItemNameById(other), 0) } if strings.Contains(s, "%a") { s = strings.Replace(s, "%a", pokemon.GetInstance().GetAbilityNameById(other+1), 0) } if strings.Contains(s, "%p") { s = strings.Replace(s, "%p", pokemon.GetInstance().GetPokemonName(other, 0), 0) } } b.WriteToHist(s + "\n") }
func (b *Battle) receivedMoveMessage(_packet *pnet.QTPacket, _player int) { move := int(_packet.ReadUint16()) part := int(_packet.ReadUint8()) msgType := int(_packet.ReadUint8()) foe := int(_packet.ReadUint8()) other := int(_packet.ReadUint16()) q := _packet.ReadString() s := pokemon.GetInstance().GetMoveMessage(move, part) if len(s) == 0 { fmt.Printf("Could not find message %d part %d\n", move, part) return } s = strings.Replace(s, "%s", b.currentPoke(_player).Nick, 0) s = strings.Replace(s, "%ts", b.players[_player].Nick, 0) var tmp int = 0 if _player == 0 { tmp = 1 } s = strings.Replace(s, "%tf", b.players[tmp].Nick, 0) if msgType != -1 { s = strings.Replace(s, "%t", puh.GetTypeValueById(msgType), 0) } if foe != -1 { s = strings.Replace(s, "%f", b.currentPoke(foe).Nick, 0) } if other != -1 && strings.Contains(s, "%m") { s = strings.Replace(s, "%m", pokemon.GetInstance().GetMoveNameById(other), 0) } s = strings.Replace(s, "%d", string(other), 0) s = strings.Replace(s, "%q", q, 0) if other != -1 && strings.Contains(s, "%i") { s = strings.Replace(s, "%i", pokemon.GetInstance().GetItemNameById(other), 0) } if other != -1 && strings.Contains(s, "%a") { s = strings.Replace(s, "%a", pokemon.GetInstance().GetAbilityNameById(other+1), 0) } if other != -1 && strings.Contains(s, "%p") { s = strings.Replace(s, "%p", pokemon.GetInstance().GetPokemonName(other, 0), 0) } b.WriteToHist(s + "\n") }