public void setInit(int mod) { Dice roller = new Dice(); string initRoll = "1d20+" + mod; var result = roller.Parse(initRoll); userHub.CurrentUser(Context.ConnectionId).Init = result[0][0] + result[0][1]; userHub.UpdateUsers(); Clients.All.broadcastMessage(Clients.Caller.userName, "init - " + userHub.CurrentUser(Context.ConnectionId).Init); _log.Add(new KeyValuePair <string, object>(Clients.Caller.userName, "init - " + userHub.CurrentUser(Context.ConnectionId).Init)); }
public void SendDie(string name, string msg, string die, int numRolls) { Dice roller = new Dice(); // Call the broadcastMessage method to update clients. int runningTotal = 0; for (int i = 0; i < numRolls; i++) { var parsedRolls = roller.Parse(die); runningTotal = runningTotal + parsedRolls[0].Sum(); string counter = (numRolls - i).ToString(); Clients.All.broadcastDice(counter, parsedRolls); _log.Add(new KeyValuePair <string, object>(counter, parsedRolls.ToArray())); } int avg = runningTotal / numRolls; Clients.All.broadcastMessage("Avg", avg); Clients.All.broadcastMessage("Sum", runningTotal); Clients.All.broadcastMessage(name, msg); _log.Add(new KeyValuePair <string, object>(name, msg)); }