当前位置: 首页>>代码示例>>Golang>>正文


Golang QTPacket.ReadUint16方法代码示例

本文整理汇总了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
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:28,代码来源:teampoke.go

示例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
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:7,代码来源:battlemove.go

示例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")
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:35,代码来源:battle.go

示例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))
	}
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:8,代码来源:battle.go

示例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
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:12,代码来源:playerteam.go

示例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
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:12,代码来源:qcolor.go

示例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)
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:14,代码来源:battle.go

示例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")
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:45,代码来源:battle.go

示例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
	}
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:37,代码来源:battle.go

示例10: clockStop

func (b *Battle) clockStop(_packet *pnet.QTPacket, _player int) {
	index := _player % 2
	b.remainingTime[index] = int(_packet.ReadUint16())
	b.ticking[index] = false
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:5,代码来源:battle.go

示例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
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:6,代码来源:battle.go

示例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())
	}
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:5,代码来源:battle.go

示例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))
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:4,代码来源:battle.go


注:本文中的Network.QTPacket.ReadUint16方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。