static DiceRoll CreateRoll(string command, CardDto cardDto, DndViewer viewer) { string parameterStr = command.EverythingAfter("(").EverythingBeforeLast(")"); string[] parameters = parameterStr.Split(','); if (parameters.Length < 2) { return(null); } DiceRoll diceRoll = new DiceRoll(DiceRollType.ViewerRoll); diceRoll.AddTrailingEffects(viewer.TrailingEffects); HueSatLight hueSatLight = new HueSatLight(viewer.DieBackColor); CorrectHueShifts(diceRoll, hueSatLight); diceRoll.DieTotalMessage = $"{cardDto.Card.UserName}'s {cardDto.Card.CardName}"; diceRoll.TextOutlineColor = viewer.DieTextColor; diceRoll.TextFillColor = viewer.DieBackColor; diceRoll.DiceGroup = DiceGroup.Viewers; diceRoll.RollScope = RollScope.Viewer; diceRoll.RollID = cardDto.InstanceID; diceRoll.Viewer = cardDto.Card.UserName; for (int i = 0; i < parameters.Length; i += 2) { string dieLabel = parameters[i + 1].Trim(); string dieStr = parameters[i].Trim(); if (dieStr.Contains("save:")) { foreach (int targetCharacterId in cardDto.TargetCharacterIds) { DiceDto diceDto = AddDieStr(diceRoll, cardDto, viewer, dieStr, dieLabel, targetCharacterId); diceDto.DieCountsAs = DieCountsAs.savingThrow; } } else { AddDieStr(diceRoll, cardDto, viewer, dieStr, dieLabel); } } savedCardsForViewerDieRolls.Add(cardDto); return(diceRoll); }