Example #1
0
//创建一个角色对象
func NewCharacter(id string, givenName, familyName string, attributes map[string]*attribute.AttributeLike) *Character {
	var c = &Character{
		Id:                   id,
		GivenName:            givenName,
		FamilyName:           familyName,
		EventEmitterBase:     event.NewEventEmitter(),
		AttributeCarrierBase: attribute.NewAttributeCarrier(),
		EffectCarrierBase:    effect.NewEffectCarrier(),
		SkillCarrierBase:     skill.NewSkillCarrierBase(),
	}
	return c
}
Example #2
0
//创建1场战斗,选定作战多方
func NewBattle(filedLen int, players ...*player.Player) *Battle {
	b := &Battle{
		Desc:                 "",
		EventEmitterBase:     event.NewEventEmitter(),
		EffectCarrierBase:    effect.NewEffectCarrier(),
		Players:              make(map[string]*player.Player),
		PlayerCharacters:     make(map[string]map[string]*Warrior),
		PlayerCharactersList: make(map[string][]*Warrior),
		Field:                NewField(filedLen),
		Status:               STATUS_INIT,
		Report:               NewBattleReport(),
		//创建行动顺序链表(上限为:玩家人数*10,就是每个玩家最多10个英雄参战)
		ActSeq: linkedList.NewSortedLinkedList(len(players)*10, compareWarriorActSeq),
	}
	//初始化用户角色集合
	for _, v := range players {
		b.Players[v.Id] = v
		b.PlayerCharacters[v.Id] = make(map[string]*Warrior)
		b.PlayerCharactersList[v.Id] = make([]*Warrior, 0)
	}
	return b
}