Exemplo n.º 1
0
/*
The default is mostly:

1 SourceName
2 TargetName
3 AttackerName
4 InflictorName
5 AttackerIsillusion
6 TargetIsIllusion
7 Value
8 Health
9 Timestamp
10 TargetSourceName
11 TimestampRaw
12 AttackerIsHero
13 TargetIsHero
*/
func (c combatLogParser) parse(obj *dota.CSVCMsg_GameEvent) CombatLogEntry {
	keys := obj.GetKeys()

	var v CombatLogEntry
	t := dota.DOTA_COMBATLOG_TYPES(keys[0].GetValByte())
	switch t {
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_ABILITY:
		v = &CombatLogAbility{}
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_ABILITY_TRIGGER:
		v = &CombatLogAbilityTrigger{}
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_DAMAGE:
		v = &CombatLogDamage{}
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_DEATH:
		v = &CombatLogDeath{}
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_GAME_STATE:
		v = &CombatLogGameState{}
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_GOLD:
		v = &CombatLogGold{}
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_HEAL:
		v = &CombatLogHeal{}
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_ITEM:
		v = &CombatLogItem{}
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_LOCATION:
		v = &CombatLogLocation{}
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_MODIFIER_ADD:
		v = &CombatLogModifierAdd{}
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_MODIFIER_REMOVE:
		v = &CombatLogModifierRemove{}
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_PURCHASE:
		v = &CombatLogPurchase{}
		// printCombatLogKeys(v, keys)
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_XP:
		v = &CombatLogXP{}
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_BUYBACK:
		v = &CombatLogBuyback{}
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_PLAYERSTATS:
		v = &CombatLogPlayerstats{}
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_TEAM_BUILDING_KILL:
		v = &CombatLogTeamBuildingKill{}
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_KILLSTREAK:
		v = &CombatLogKillStreak{}
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_MULTIKILL:
		v = &CombatLogMultikill{}
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_FIRST_BLOOD:
		// TODO: map DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_FIRST_BLOOD
		return nil
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_MODIFIER_REFRESH:
		// TODO: map DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_MODIFIER_REFRESH
		return nil
	default:
		pp(t, keys)
		return nil
	}

	c.assign(v, keys)
	return v
}
Exemplo n.º 2
0
func (p *Parser) onGameEvent(tick int, obj *dota.CSVCMsg_GameEvent) {
	desc := p.GameEventMap[obj.GetEventid()]
	dName := desc.GetName()

	switch dName {
	case "hltv_versioninfo":
		// version : <*>type:5 val_byte:1
	case "hltv_message":
		// text : <*>type:1 val_string:"Please wait for broadcast to start ..."
	case "hltv_status":
		// clients : <*>type:3 val_long:523
		// slots : <*>type:3 val_long:3840
		// proxies : <*>type:4 val_short:59
		// master : <*>type:1 val_string:"146.66.152.49:28027"
	case "dota_combatlog":
		if p.OnCombatLog != nil {
			if log := p.combatLogParser.parse(obj); log != nil {
				p.OnCombatLog(log)
			}
		}
	case "dota_chase_hero":
		// target1 : <*>type:4 val_short:1418
		// target2 : <*>type:4 val_short:0
		// type : <*>type:5 val_byte:0
		// priority : <*>type:4 val_short:15
		// gametime : <*>type:2 val_float:2710.3667
		// highlight : <*>type:6 val_bool:false
		// target1playerid : <*>type:5 val_byte:1
		// target2playerid : <*>type:5 val_byte:32
		// eventtype : <*>type:4 val_short:1
	case "dota_tournament_item_event":
		// event_type : <*>type:4 val_short:0  => witness first blood
		// event_type : <*>type:4 val_short:1  => witness killing spree
		// event_type : <*>type:4 val_short:3  => witness hero deny
	default:
		dKeys := desc.GetKeys()
		spew.Println(dName)
		for n, key := range obj.GetKeys() {
			spew.Println(dKeys[n].GetName(), ":", key)
		}
	}
}
Exemplo n.º 3
0
/*
The default is mostly:

1 SourceName
2 TargetName
3 AttackerName
4 InflictorName
5 AttackerIsillusion
6 TargetIsIllusion
7 Value
8 Health
9 Timestamp
10 TargetSourceName
11 TimestampRaw
12 AttackerIsHero
13 TargetIsHero
*/
func (c combatLogParser) parse(obj *dota.CSVCMsg_GameEvent) CombatLogEntry {
	keys := obj.GetKeys()

	var v CombatLogEntry
	t := dota.DOTA_COMBATLOG_TYPES(keys[0].GetValByte())
	switch t {
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_ABILITY:
		v = &CombatLogAbility{}
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_DAMAGE:
		v = &CombatLogDamage{}
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_DEATH:
		v = &CombatLogDeath{}
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_GAME_STATE:
		v = &CombatLogGameState{}
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_GOLD:
		v = &CombatLogGold{}
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_HEAL:
		v = &CombatLogHeal{}
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_ITEM:
		v = &CombatLogItem{}
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_LOCATION:
		v = &CombatLogLocation{}
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_MODIFIER_ADD:
		v = &CombatLogModifierAdd{}
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_MODIFIER_REMOVE:
		v = &CombatLogModifierRemove{}
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_PURCHASE:
		v = &CombatLogPurchase{}
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_XP:
		v = &CombatLogXP{}
	case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_BUYBACK:
		v = &CombatLogBuyback{}
	default:
		pp(t, keys)
		return nil
	}

	c.assign(v, keys)
	return v
}