本文整理汇总了Golang中Network.QTPacket.ReadUint16方法的典型用法代码示例。如果您正苦于以下问题:Golang QTPacket.ReadUint16方法的具体用法?Golang QTPacket.ReadUint16怎么用?Golang QTPacket.ReadUint16使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Network.QTPacket
的用法示例。
在下文中一共展示了QTPacket.ReadUint16方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewTeamPokeFromPacket
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
}
示例2: NewBattleMoveFromPacket
func NewBattleMoveFromPacket(_packet *pnet.QTPacket) *BattleMove {
battleMove := NewBattleMoveFromId(int(_packet.ReadUint16()))
battleMove.CurrentPP = int(_packet.ReadUint8())
battleMove.TotalPP = int(_packet.ReadUint8())
return battleMove
}
示例3: receivedAbilityMessage
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")
}
示例4: receivedStraigthDamage
func (b *Battle) receivedStraigthDamage(_packet *pnet.QTPacket, _player int) {
damage := int(_packet.ReadUint16())
if _player == b.me {
b.WriteToHist(fmt.Sprintf("%v lost %d HP! (%d%% of its health)", b.currentPoke(_player).Nick, (damage*100)/b.myTeam.Pokes[0].TotalHP))
} else {
b.WriteToHist(fmt.Sprintf("%v lost %d%% of its health!", b.currentPoke(_player).Nick, damage))
}
}
示例5: NewPlayerTeamFromPacket
func NewPlayerTeamFromPacket(_packet *pnet.QTPacket) *PlayerTeam {
playerTeam := PlayerTeam{}
playerTeam.Nick = _packet.ReadString()
playerTeam.Info = _packet.ReadString()
playerTeam.LoseMessage = _packet.ReadString()
playerTeam.WinMessage = _packet.ReadString()
playerTeam.avatar = int(_packet.ReadUint16())
playerTeam.DefaultTier = _packet.ReadString()
playerTeam.Team = NewTeamFromPacket(_packet)
return &playerTeam
}
示例6: NewQColorFromPacket
func NewQColorFromPacket(_packet *pnet.QTPacket) *QColor {
color := QColor{}
color.Spec = _packet.ReadUint8()
color.Alpha = _packet.ReadUint16()
color.Red = _packet.ReadUint16()
color.Green = _packet.ReadUint16()
color.Blue = _packet.ReadUint16()
color.Pad = _packet.ReadUint16()
color.Html = ">"
return &color
}
示例7: receivedChangeHp
func (b *Battle) receivedChangeHp(_packet *pnet.QTPacket, _player int) {
newHp := int(_packet.ReadUint16())
if _player == b.me {
b.myTeam.Pokes[0].CurrentHP = newHp
b.currentPoke(_player).LastKnownPercent = newHp
b.currentPoke(_player).LifePercent = (newHp * 100) / b.myTeam.Pokes[0].TotalHP
} else {
b.currentPoke(_player).LastKnownPercent = newHp
b.currentPoke(_player).LifePercent = newHp
}
// Send HP update to PU Client
SendBattleEvent_ChangeHP(b.owner.player, 0, newHp)
}
示例8: receivedMoveMessage
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")
}
示例9: receivedTempPokeChange
func (b *Battle) receivedTempPokeChange(_packet *pnet.QTPacket, _player int) {
id := int(_packet.ReadUint8())
switch id {
case TEMPPOKECHANGE_TEMPMOVE:
fallthrough
case TEMPPOKECHANGE_DEFMOVE:
slot := int(_packet.ReadUint8())
newMove := NewBattleMoveFromId(int(_packet.ReadUint16()))
b.displayedMoves[slot] = newMove
if id == TEMPPOKECHANGE_DEFMOVE {
b.myTeam.Pokes[0].Moves[slot] = newMove
}
// TODO: Send updatePokes(player) to PU client
case TEMPPOKECHANGE_TEMPPP:
slot := int(_packet.ReadUint8())
pp := int(_packet.ReadUint8())
b.displayedMoves[slot].CurrentPP = pp
// TODO: Send updateMovePP(slot) to PU client
case TEMPPOKECHANGE_TEMPSPRITE:
// TODO: Implement
case TEMPPOKECHANGE_DEFINITEFORME:
poke := int(_packet.ReadUint8())
newForm := int(_packet.ReadUint16())
if b.isOut(poke) {
b.currentPoke(b.slot(_player, poke)).UID.PokeNum = newForm
// TODO: Send updatePokes(player) to PU client
}
case TEMPPOKECHANGE_AESTHETICFORME:
newForm := int(_packet.ReadUint16())
b.currentPoke(_player).UID.SubNum = newForm
// TODO: Send updatePokes(player) to PU client
}
}
示例10: clockStop
func (b *Battle) clockStop(_packet *pnet.QTPacket, _player int) {
index := _player % 2
b.remainingTime[index] = int(_packet.ReadUint16())
b.ticking[index] = false
}
示例11: clockStart
func (b *Battle) clockStart(_packet *pnet.QTPacket, _player int) {
index := _player % 2
b.remainingTime[index] = int(_packet.ReadUint16())
b.startingTime[index] = time.Now().UnixNano()
b.ticking[index] = true
}
示例12: receiveDynamicStats
func (b *Battle) receiveDynamicStats(_packet *pnet.QTPacket, _player int) {
for i := 0; i < 5; i++ {
b.myTeam.Pokes[_player/2].Stats[i] = int(_packet.ReadUint16())
}
}
示例13: receivedUseAttack
func (b *Battle) receivedUseAttack(_packet *pnet.QTPacket, _player int) {
attack := int(_packet.ReadUint16())
b.WriteToHist(fmt.Sprintf("%s used %s!\n", b.currentPoke(_player).Nick, pokemon.GetInstance().GetMoveById(attack).Identifier))
}