Пример #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
}
Пример #2
0
//创建一个属性(名称、描述、原始值)
func NewAttribute(name, desc string, rawValue float64) *Attribute {
	a := &Attribute{
		name: name,
		desc: desc,
		val: &Value{
			raw:                  rawValue,
			totalAdditionVal:     0,
			totalAdditionPercent: 0,
			adders:               make([]*Adder, 0),
		},
		EventEmitterBase: event.NewEventEmitter(),
	}
	a.val.attRef = a
	return a
}
Пример #3
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
}
Пример #4
0
func NewEffectCarrier() *EffectCarrierBase {
	return &EffectCarrierBase{
		EventEmitterBase: event.NewEventEmitter(),
		allEffects:       make(map[string][]Effect, 0),
	}
}