/// <summary> 组装出招Vo </summary> /// <param name="roleid"></param> /// <param name="hitids"></param> private MovesVo BuildMovesVo(Int64 roleid, List <double> hitids) { var move = new MovesVo { attackId = roleid, hitIds = hitids, rolesA = ConvertRoleFightVo(GetRoles(true, true)), rolesB = ConvertRoleFightVo(GetRoles(false, true)), times = Round }; if (!FirstRoles.Any()) { move.yinA = 0; } else { var dic = FirstRoles.First(); move.yinA = AllRoles.ContainsKey(dic.Value) ? YinCount[AllRoles[dic.Value].user_id] : 0; } if (!AfterRoles.Any()) { move.yinB = 0; } else { var dic = AfterRoles.First(); move.yinB = AllRoles.ContainsKey(dic.Value) ? YinCount[AllRoles[dic.Value].user_id] : 0; } return(move); }
/// <summary> 获取某一方全体武将 </summary> /// <param name="flag">要获取的方位 </param> /// <param name="sign">空缺位置是否为null</param> private List <Role> GetRoles(bool flag, bool sign) { var roles = new List <Role>(); var rs = flag ? FirstRoles : AfterRoles; if (!sign) { roles.AddRange(from item in rs.Values where AllRoles.ContainsKey(item) select AllRoles[item]); } else { for (int i = 1; i <= 5; i++) { if (rs.ContainsKey(i)) { var roleid = rs[i]; if (AllRoles.ContainsKey(roleid)) { roles.Add(AllRoles[roleid]); } } else { roles.Add(null); } } } return(roles); }
/// <summary> 攻击 </summary> /// <param name="roleid">攻击的武将Id</param> /// <param name="flag">是否全体攻击</param> /// <param name="sign">是否增加气力</param> private MovesVo Attack(Int64 roleid, bool flag, bool sign) { if (!AllRoles.ContainsKey(roleid)) { return(null); } var roles = new List <Role>(); var role = AllRoles[roleid]; if (sign) { role.angerCount += 1; } if (flag) { roles = GetRoles(!IsFirst, false); } else { var r = GetRole(); if (r == null) { return(null); } roles.Add(r); } Attack(role, roles, flag); var move = BuildMovesVo(role.id, roles.Select(m => Convert.ToDouble(m.id)).ToList()); RemoveRoleState(); return(move); }
public virtual string CheckAndSetRoles(string roles) { if (string.IsNullOrWhiteSpace(roles)) return string.Join(',', RoleNames.Unregistered, RoleNames.Registered); var rolesNames = roles.Split(',').Select(x => x.Trim()).ToList() .Where(x => AllRoles.ContainsKey(x)); return string.Join(',', rolesNames); }