public override void Dispose() { if (LayoutRoot != null) { var dataContext = LayoutRoot.DataContext as SparkViewModel; if (dataContext != null) { dataContext.Dispose(); } if (Column != null) { Column.ClearValue(SparklineBase.ItemsSourceProperty); } Column = null; if (Line != null) { Line.ClearValue(SparklineBase.ItemsSourceProperty); } Line = null; if (Area != null) { Area.ClearValue(SparklineBase.ItemsSourceProperty); } Area = null; if (WinLoss != null) { WinLoss.ClearValue(SparklineBase.ItemsSourceProperty); } WinLoss = null; } base.Dispose(); }
public async Task handleInput(SocketMessage m) { string input = m.ToString(); string[] toParse = input.Split(' '); string command = toParse[0]; int inputLen = toParse.Length; if (command == "") { return; } else if (command == Constants.Dota.COMMAND_PAIR) { if (inputLen > 2 || inputLen < 2) { await m.Channel.SendMessageAsync("Incorrect usage. Use " + Constants.Dota.COMMAND_PAIR + " your SteamID."); } else { users[m.Author.Id] = toParse[1]; await m.Channel.SendMessageAsync(m.Author.Mention + " has been paired with SteamID " + toParse[1]); saveUserMap(); } } else if (command == Constants.Dota.COMMAND_GETPROFILE) { if (users.ContainsKey(m.Author.Id)) { string id = users[m.Author.Id]; string s = await callOpenDotaForProfile(id); UserObject user = JsonConvert.DeserializeObject <UserObject>(s); s = await callOpenDotaForWinLoss(id); WinLoss wl = JsonConvert.DeserializeObject <WinLoss>(s); float fwinrate = (((float)wl.win) / ((float)wl.win + (float)wl.lose)); fwinrate *= 100; string winrate = fwinrate.ToString("0.00"); string rank = getRank(user.rank_tier); await m.Channel.SendMessageAsync(m.Author.Mention + " here is your Dota 2 profile: ```" + "Nickname: " + user.profile.personaname + "\n" + "Rank: " + rank + "\n" + "Wins: " + wl.win + " Losses: " + wl.lose + " Winrate: " + winrate + "%" + "\n" + "```" + "\n" + "Full profile at: https://www.opendota.com/players/" + id); } } }
bool ProcessEvent(bool withSound = true) { GameEvent evt = engine.getQueuedEvent(); if (evt == null) { return(false); } if (evt is TileChangedEvent) { TileChangedEvent sEvt = (TileChangedEvent)evt; tiles [sEvt.x, sEvt.y].SetTexture(tileTextures [sEvt.currentPiece.GetHashCode()]); hasPlaced [sEvt.x, sEvt.y] = true; if (withSound) { int randomNumber = Random.Range(0, playSounds.Length); AudioClip clip = playSounds [randomNumber]; Debug.Log(randomNumber.ToString() + ", " + clip.ToString()); playSound(clip); } autoSave(); Counter.UpdateValue(engine.getPieceCount(), engine.getRemainingArrowCount()); } if (evt is CurrentTileChangedEvent) { CurrentTileChangedEvent sEvt = (CurrentTileChangedEvent)evt; GameObject.Find("TileCurrent").GetComponent <Tile> ().SetTexture(tileTextures [sEvt.newCurrentTile.GetHashCode()]); } if (evt is StoredTileChangedEvent) { StoredTileChangedEvent sEvt = (StoredTileChangedEvent)evt; GameObject.Find("TileStored").GetComponent <Tile> ().SetTexture(tileTextures [sEvt.newStoredTile.GetHashCode()]); AudioClip clip = swapSound; playSound(clip); } if (evt is GameWonEvent) { Debug.Log("WINNER"); Celebration.globalWin(); Stats.addWin(generatorId); WinLoss.ShowWin(); } if (evt is GameLostEvent) { Debug.Log("Loser"); WinLoss.ShowLoss(); } return(true); }
/// <summary> /// Constructor. /// </summary> /// <param name="gameRoundId">Game round id.</param> /// <param name="persistentGameDataId">The persistent game data id.</param> /// <param name="entropyReveal">Entropy Reveal.</param> /// <param name="players">Player addresses.</param> /// <param name="winAmounts">Win amounts.</param> /// <param name="progressivePotWinLoss">Progressive Pot Win/Loss.</param> /// <param name="gameResult">Game Result (encoded).</param> /// <param name="historyToRecord">History to record (encoded).</param> public EndGameRoundEventOutput([EventOutputParameter(ethereumDataType: "bytes32", order: 1, indexed: true)] GameRoundId gameRoundId, [EventOutputParameter(ethereumDataType: "bytes32", order: 2, indexed: true)] byte[] persistentGameDataId, [EventOutputParameter(ethereumDataType: "bytes32", order: 3, indexed: false)] Seed entropyReveal, [EventOutputParameter(ethereumDataType: "address[]", order: 4, indexed: false)] AccountAddress[] players, [EventOutputParameter(ethereumDataType: "uint256[]", order: 5, indexed: false)] DataTypes.Primitives.Token[] winAmounts, [EventOutputParameter(ethereumDataType: "int256", order: 6, indexed: false)] WinLoss progressivePotWinLoss, [EventOutputParameter(ethereumDataType: "bytes", order: 7, indexed: false)] byte[] gameResult, [EventOutputParameter(ethereumDataType: "bytes", order: 8, indexed: false)] byte[] historyToRecord) {
private void MainGame() { // 赤が勝ったら if (RedPartGet == gameRule.PartGet && GameState == State.Main) { winLoss = GameObject.Find("ResultUI").GetComponent <WinLoss>(); Debug.Log("RedWin"); //GameState = State.Title; winLoss.WinOrLoss(1); } // 青が勝ったら if (BluePartGet == gameRule.PartGet && GameState == State.Main) { winLoss = GameObject.Find("ResultUI").GetComponent <WinLoss>(); Debug.Log("BlueWin"); //GameState = State.Title; winLoss.WinOrLoss(2); } }
/// <inheritdoc /> public Task SaveEndRoundAsync(GameRoundId gameRoundId, BlockNumber blockNumberCreated, TransactionHash transactionHash, WinAmount[] winAmounts, WinLoss progressivePotWinLoss, byte[] gameResult, byte[] history) { return(this._database.ExecuteAsync(storedProcedure: @"Games.GameRound_Complete", new { GameRoundId = gameRoundId, BlockNumber = blockNumberCreated, TransactionHash = transactionHash, WinAmounts = this._winAmountTableBuilder.Build(winAmounts.Select(Convert)), ProgressiveWinLoss = progressivePotWinLoss, GameResult = gameResult, History = history })); }
public void doBet(WinLoss w) { switch (w) { case WinLoss.Dealer: myBet = 0; break; case WinLoss.Player: myCash += Bet * 2; myBet = 0; break; case WinLoss.Push: myCash += Bet; myBet = 0; break; default: break; } }
public void ShouldComputeWinLossForBrewers() { var result = WinLoss.CalculateWinLossPercentage(teams.First(t => t.TeamName == "Brewers")); Assert.AreEqual(0, result); }
private void worker_LoadShipDataThread(object sender) { m_npage = 1; m_databaseMutex.WaitOne(); try { m_database = new Dictionary <string, WinLoss>(); WinLoss wl = new WinLoss(); wl.m_wins = 1; wl.m_deaths = 1; m_database.Add(m_ownShipTypeId, wl); } finally { m_databaseMutex.ReleaseMutex(); } while (m_backworker_running) { try { Debug.WriteLine("worker_LoadShipData() get HTML"); DateTime dt = DateTime.Now; dt = dt.AddYears(-1); string lastyear = dt.ToString("yyyyMMdd0000"); string xpage = String.Format("{0}", m_npage); //https://zkillboard.com/api/solo/shipTypeID/585/startTime/201709010000/page/19/ string resp = new WebClient().DownloadString("https://zkillboard.com/api/solo/shipTypeID/" + m_ownShipTypeId + "/startTime/" + lastyear + "/page/" + xpage + "/"); if (resp.Length <= 0 || !resp.StartsWith("[")) { break; } dynamic page = JsonConvert.DeserializeObject(resp); for (int i = 0; m_backworker_running && i < page.Count; i++) { string attacker = page[i].attackers[0].ship_type_id; string attackerw = page[i].attackers[0].weapon_type_id; string victim = page[i].victim.ship_type_id; //Debug.WriteLine("Attacker: " + attacker + " weapon: " + attackerw + " victim: " + victim); if (attacker == null || victim == null) { continue; } m_databaseMutex.WaitOne(); try { if (attacker == m_ownShipTypeId && victim == m_ownShipTypeId) { continue; } else if (attacker == m_ownShipTypeId) { WinLoss otherShip = null; if (m_database.ContainsKey(victim)) { otherShip = m_database[victim]; } else { otherShip = new WinLoss(); m_database.Add(victim, otherShip); } otherShip.m_deaths++; } else if (victim == m_ownShipTypeId) { WinLoss otherShip = null; if (m_database.ContainsKey(attacker)) { otherShip = m_database[attacker]; } else { otherShip = new WinLoss(); m_database.Add(attacker, otherShip); } otherShip.m_wins++; } } finally { m_databaseMutex.ReleaseMutex(); } } m_npage++; Thread.Sleep(2000); // gives a race condition when changing the vessel //dataGridViewMain.Invoke((MethodInvoker)delegate { UpdateStatus(false, false, false, false); }); } catch (Exception) { } } m_backworker_running = true; m_semaphore.Release(); }