public static BarModel HPBarModel(Character ch) { string temp = string.Empty; if(ch.TempHP > 0) temp = string.Format("+{0}", ch.TempHP); BarModel model = new BarModel { Max = ch.MaxHP, Min = 0, Current = Math.Max(0, ch.CurrentHP), Class = "hp", Label = string.Format("HP: {0}{1}/{2}", ch.CurrentHP, temp, ch.MaxHP) }; model.AddConditionalClass(50, "Bloodied"); return model; }
public CharacterUpdateEvent(Character ch) : base(PartyEventType.CharacterUpdate) { ID = ch.ID; Name = ch.Name; HP = ch.CurrentHP; TempHP = ch.TempHP; Surges = ch.CurrentSurges; DeathSaves = ch.DeathSaves; }
public static BarModel SurgeBarModel(Character ch) { BarModel model = new BarModel { Max = ch.MaxSurges, Min = 0, Current = ch.CurrentSurges, Class = "surges", Label = string.Format("Surges: {0}/{1}", ch.CurrentSurges, ch.MaxSurges) }; return model; }
public ActionResult Join(Character character) { string toHash = character.Name; character.Token = Convert.ToBase64String(_hash.ComputeHash(Encoding.UTF8.GetBytes(toHash))); if (Party.ContainsKey(character.Token)) { return Json(new PartyJoinedEvent { Success = true, Message="Character is already in the party", ExistingMember=true, ID=character.ID, Token = character.Token, PartyMembers = Party.Values.Where(p => !p.Token.Equals(character.Token)).ToArray()}); } CacheImage(character.Portrait); BroadcastEvent(new CharacterJoinedEvent { Character = character }); var party = Party.Values.ToArray(); Party[character.Token] = character; return Json(new PartyJoinedEvent { Success = true, Message = "Party joined", ExistingMember=false, ID=character.ID, Token = character.Token, PartyMembers = party }); }