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


Golang Network.QTPacket类代码示例

本文整理汇总了Golang中Network.QTPacket的典型用法代码示例。如果您正苦于以下问题:Golang QTPacket类的具体用法?Golang QTPacket怎么用?Golang QTPacket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QTPacket类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: 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

示例2: receivedStatusMessage

func (b *Battle) receivedStatusMessage(_packet *pnet.QTPacket, _player int) {
	status := int(_packet.ReadUint8())
	var statusStr string
	switch status {
	case STATUSFEELING_FEELCONFUSION:
		statusStr = fmt.Sprintf("%s is confused!\n", b.currentPoke(_player))
	case STATUSFEELING_HURTCONFUSION:
		statusStr = "It hurt itself in its confusion!\n"
	case STATUSFEELING_FREECONFUSION:
		statusStr = fmt.Sprintf("%s snapped out of its confusion!\n", b.currentPoke(_player))
	case STATUSFEELING_PREVPARALYSED:
		statusStr = fmt.Sprintf("%s is paralyzed! It can't move!\n", b.currentPoke(_player))
	case STATUSFEELING_FEELASLEEP:
		statusStr = fmt.Sprintf("%s is fast asleep!\n", b.currentPoke(_player))
	case STATUSFEELING_FREEASLEEP:
		statusStr = fmt.Sprintf("%s woke up!\n", b.currentPoke(_player))
	case STATUSFEELING_HURTBURN:
		statusStr = fmt.Sprintf("%s is hurt by its burn!\n", b.currentPoke(_player))
	case STATUSFEELING_HURTPOISON:
		statusStr = fmt.Sprintf("%s is hurt by poison!\n", b.currentPoke(_player))
	case STATUSFEELING_PREVFROZEN:
		statusStr = fmt.Sprintf("%s if frozen solid!\n", b.currentPoke(_player))
	case STATUSFEELING_FREEFROZEN:
		statusStr = fmt.Sprintf("%s thawed out!\n", b.currentPoke(_player))
	}
	b.WriteToHist(statusStr)
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:27,代码来源:battle.go

示例3: battleMessage

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

示例4: NewBasicPlayerInfoFromPacket

func NewBasicPlayerInfoFromPacket(_packet *pnet.QTPacket) *BasicPlayerInfo {
	basicPlayerInfo := &BasicPlayerInfo{}
	basicPlayerInfo.Nick = _packet.ReadString()
	basicPlayerInfo.Info = _packet.ReadString()
	
	return basicPlayerInfo
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:7,代码来源:basicplayerinfo.go

示例5: NewShallowShownPokeFromPacket

func NewShallowShownPokeFromPacket(_packet *pnet.QTPacket) *ShallowShownPoke {
	shallowShownPoke := ShallowShownPoke{UID: NewUniqueIdFromPacket(_packet),
		Level:  int(_packet.ReadUint8()),
		Gender: int(_packet.ReadUint8()),
		Item:   _packet.ReadBool()}
	return &shallowShownPoke
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:7,代码来源:shallowshownpoke.go

示例6: NewTeamFromPacket

func NewTeamFromPacket(_packet *pnet.QTPacket) *Team {
	team := Team{Pokes: make([]*TeamPoke, 6)}
	team.Gen = int(_packet.ReadUint8())
	for i := 0; i < 6; i++ {
		team.Pokes[i] = NewTeamPokeFromPacket(_packet)
	}
	return &team
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:8,代码来源:team.go

示例7: receivedHit

func (b *Battle) receivedHit(_packet *pnet.QTPacket) {
	number := _packet.ReadUint8()
	extraStr := "!"
	if number > 1 {
		extraStr = "s!"
	}
	b.WriteToHist(fmt.Sprintf("Hit %d time%s\n", number, extraStr))
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:8,代码来源:battle.go

示例8: 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

示例9: receivedChangePP

func (b *Battle) receivedChangePP(_packet *pnet.QTPacket) {
	moveNum := int(_packet.ReadUint8())
	newPP := int(_packet.ReadUint8())
	b.displayedMoves[moveNum].CurrentPP = newPP
	b.myTeam.Pokes[0].Moves[moveNum].CurrentPP = newPP

	// Send updateMovePP to PUClient
	SendBattleEvent_ChangePP(b.owner.player, 0, moveNum, newPP)
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:9,代码来源:battle.go

示例10: receivedSubstitute

func (b *Battle) receivedSubstitute(_packet *pnet.QTPacket, _player int) {
	isSub := _packet.ReadBool()
	b.currentPoke(_player).Sub = isSub
	if _player == b.me {
		// TODO: Send updateMyPoke to PU client
	} else {
		// TODO: Send updateOppPoke to PU client
	}
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:9,代码来源:battle.go

示例11: receivedRated

func (b *Battle) receivedRated(_packet *pnet.QTPacket) {
	rated := "Unrated"
	if _packet.ReadBool() {
		rated = "Rated"
	}
	b.WriteToHist("Rule: " + rated + "\n")

	// TODO: Print clauses
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:9,代码来源:battle.go

示例12: NewRearrangeChoiceFromPacket

func NewRearrangeChoiceFromPacket(_packet *pnet.QTPacket) *RearrangeChoice {
	rearrangeChoice := RearrangeChoice{}
	rearrangeChoice.PokeIndexes = make([]int, 6)
	for i := 0; i < 6; i++ {
		rearrangeChoice.PokeIndexes[i] = int(_packet.ReadUint8())
	}

	return &rearrangeChoice
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:9,代码来源:battlechoice.go

示例13: NewBattleDynamicInfoFromPacket

func NewBattleDynamicInfoFromPacket(_packet *pnet.QTPacket) *BattleDynamicInfo {
	battleDynamicInfo := BattleDynamicInfo{}
	battleDynamicInfo.Boosts = make([]byte, 7)
	for i := 0; i < 7; i++ {
		battleDynamicInfo.Boosts[i] = _packet.ReadUint8()
	}
	battleDynamicInfo.Flags = _packet.ReadUint8()

	return &battleDynamicInfo
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:10,代码来源:battledynamicinfo.go

示例14: NewFullPlayerInfoFromPacket

func NewFullPlayerInfoFromPacket(_packet *pnet.QTPacket) *FullPlayerInfo {
	fullPlayerInfo := &FullPlayerInfo{}
	fullPlayerInfo.Team = NewPlayerTeamFromPacket(_packet)
	fullPlayerInfo.IsDefault = true
	fullPlayerInfo.ladderEnabled = _packet.ReadBool()
	fullPlayerInfo.showTeam = _packet.ReadBool()
	fullPlayerInfo.nameColor = NewQColorFromPacket(_packet)

	return fullPlayerInfo
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:10,代码来源:fullplayerinfo.go

示例15: engageBattle

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


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