public static void ShowResult(PlayResult result) { Time.timeScale = 0; KPresenter p = UIManager.Instance.Show(Constant.UI_RESULT); p.DataContent = result; }
public void ProcessGameResult(PlayResult result, decimal bet) { if (result == PlayResult.push) { Form.ResultText.Text = "PUSH"; Form.ResultText.Background = Brushes.Yellow; myMoney.UpdatePot(0); } else if (result == PlayResult.winner) { Form.ResultText.Text = "WINNER!"; Form.ResultText.Background = Brushes.Green; myMoney.UpdatePot(bet); } else if (result == PlayResult.loser) { Form.ResultText.Text = "LOSER"; Form.ResultText.Background = Brushes.Red; Form.ResultText.Foreground = Brushes.White; myMoney.UpdatePot(0 - bet); } else if (result == PlayResult.surrender) { Form.ResultText.Text = "SURRENDER"; Form.ResultText.Background = Brushes.Orange; myMoney.UpdatePot(0 - (bet / 2)); // Lose only half your bet on surrenders } else if (result == PlayResult.blackjack) { Form.ResultText.Text = "BLACKJACK"; Form.ResultText.Background = Brushes.Green; myMoney.UpdatePot(bet * 3 / 2); } }
/// <summary> /// Plays the given file to the specified channel. /// </summary> /// <param name="eventSocket">The EventSocket instance.</param> /// <param name="uuid">The Channel UUID.</param> /// <param name="file">The Path to the file to be played. Note: use forward slashes for path separators.</param> /// <param name="options">Options to customize playback.</param> /// <returns>A PlayResult.</returns> /// <exception cref="FileNotFoundException">Throws FileNotFoundException if FreeSwitch is unable to play the file.</exception>//todo: should it? public static async Task <PlayResult> Play(this EventSocket eventSocket, string uuid, string file, PlayOptions options = null) { // todo: implement options for playback eg a-leg, b-leg, both, using uuid_displace if (options == null) { options = new PlayOptions(); } try { // todo: what if applicationresult is null (hang up occurs before the application completes) var result = new PlayResult( await eventSocket.ExecuteApplication(uuid, "playback", file, loops: options.Loops) .ConfigureAwait(false)); if (!result.Success) { LogFailedApplicationResult(eventSocket, result); } return(result); } catch (TaskCanceledException ex) { return(new PlayResult(null)); } }
private async Task SendToBothAsync(IGameSession session, PlayResult result, int x, int y) { var msgToSend = new MoveResultMessage(result.ToString(), x, y); await messageSender.SendMessageAsync(session.PlayerOne.Socket, msgToSend); await messageSender.SendMessageAsync(session.PlayerTwo.Socket, msgToSend); }
internal async void InitialisePlay(string mixId) { if (App.Settings.PlayToken == null || App.Settings.PlayToken == string.Empty) { //TODO: Lock down user token SetResult result = await App.Engine.PlayToken(App.Settings.UserToken); if (result.errors == null || result.errors == string.Empty) { App.Settings.PlayToken = result.play_token; } } //TODO: Lock down user token PlayResult playResult = await App.Engine.Play(App.Settings.UserToken, App.Settings.PlayToken, mixId); if (playResult.errors == null || playResult.errors == string.Empty) { MediaElement playMedia = this.FindName("playMedia") as MediaElement; if (playMedia != null) { playMedia.Source = new Uri(playResult.set.track.url); playMedia.Play(); } } }
protected async Task <PlayResult> GetSuccessfulPlayResponseAsync(Account account, int bet, long number) { string requestStr = $"{_connectionSettings.PlayAddress}{Mode}?id={account.Id}&bet={bet}&number={number}"; HttpRequestMessage request; HttpResponseMessage response; do { request = new HttpRequestMessage(HttpMethod.Get, requestStr); response = await _httpClient.SendAsync(request); } while (!response.IsSuccessStatusCode); string responseStr = await response.Content.ReadAsStringAsync(); PlayResult playState = JsonConvert.DeserializeObject <PlayResult>(responseStr); if (playState == null) { throw new InvalidOperationException($"Unknown data was reseived from the external source: {responseStr}"); } if (!string.IsNullOrWhiteSpace(_playStateFilePath)) { File.WriteAllText(_playStateFilePath, responseStr); } if (!string.IsNullOrWhiteSpace(_accountFilePath)) { File.WriteAllText(_accountFilePath, JsonConvert.SerializeObject(playState.Account)); } return(playState); }
public override void SetGameOver(PlayResult result) { /** Destroys/Disables **/ /** Camera/Entities Setup **/ m_playResult = result; m_playState = PlayState.GameOver; }
private async Task SendErrorMsgToSenderAsync(IPlayer player, PlayResult result) { var msgToSend = new ChessPlayResultMessage() { Message = result.ToString() }; await messageSender.SendMessageAsync(player.Socket, msgToSend); }
public PgnTurn(int turnNumber, PgnTurnMove white, PgnTurnMove black, PlayResult result, string normalizedMoveText) { TurnNumber = turnNumber; Result = result; WhiteMove = white; BlackMove = black; MoveText = normalizedMoveText; }
/// <summary> /// Gets the resources this location would produce if worked, accounting for terrain improvements, technology, /// special resources (including Spaceport effect if you have it), city improvements, wonders, and government, /// if worked by the given city. /// </summary> public PlayResult GetResourcesForCity(City city, out BaseResourceSet resources) { TileInfo info = new TileInfo(city.Id); PlayResult result = TheEmpire.Play(Protocol.sGetHypoCityTileInfo, Id, &info); resources = info.Resources; return(result); }
/// <summary> /// Gets the resources this location would produce if worked, accounting for terrain improvements, technology, /// special resources (including Spaceport effect if you have it), and government. Does not include effects of /// city improvements (so farmland is ignored) or the Lighthouse. /// </summary> public PlayResult GetResources(out BaseResourceSet resources) { TileInfo info; PlayResult result = TheEmpire.Play(Protocol.sGetTileInfo, Id, &info); resources = info.Resources; return(result); }
public void ShowGameResults(PlayResult results) { ClearHUD(); GetUserInputController().SlideOutOfView(); GameScoreDrawer drawer = GetGameScoreDrawer(); drawer.RenderPlayResults(results); drawer.SlideIntoView(); }
public void EndGame() { if (this.modeController != null) { PlayResult results = this.modeController.GetPlayResult(); Debug.Log(results); ShowGameResults(results); } this.gameMode = null; }
public override void StartGame() { this.isGameOn = true; this.equationsLeft = GameSettings.Instance.ClassicMode_Questions; // construct our play result container result = new PlayResult(); // create new equation this.equation = Instantiate(equationPrefab, transform.position, Quaternion.identity); }
public void Play_EmptyMoveName_ThrowArgumentException() { //Arrange string moveName = "Rock"; string againstMoveName = string.Empty; Move newMove = new Move(moveName); newMove.AddKill(againstMoveName); //Act PlayResult result = newMove.Play(againstMoveName); }
public void Play_SameMove_Draw() { //Arrange string moveName = "Rock"; Move newMove = new Move(moveName); //Act PlayResult result = newMove.Play(moveName); //Assert Assert.AreEqual(PlayResult.Draw, result); }
public void Play_MoveNotOnKillList_Lose() { //Arrange string moveName = "Rock"; string againstMoveName = "Paper"; Move newMove = new Move(moveName); //Act PlayResult result = newMove.Play(againstMoveName); //Assert Assert.AreEqual(PlayResult.Lose, result); }
private void ClickPlay(MouseEventArgs e) { if (e.Button == MouseButtons.Middle) { _showMoveable = !_showMoveable; return; } else if (e.Button == System.Windows.Forms.MouseButtons.Right) { _showHint = !_showHint; return; } int xp = (int)(e.X / CELLWIDTH); int yp = (int)(e.Y / CELLHEIGHT); Tile clicked = _field.GetTileFromCoord(xp, yp); if (clicked == null) { return; } if (!_field.CanMove(clicked)) { return; } if (_selected == null || clicked == _selected) { _selected = clicked; } else { PlayResult result = _field.Play(_selected, clicked); if (result == PlayResult.Won) { MessageBox.Show("You won the game in " + Math.Ceiling(_field.GameTime.TotalSeconds) + " seconds !", "You won!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if ((result & PlayResult.NoFurtherMoves) != 0) { DialogResult boxResult = MessageBox.Show("No further moves possible :( Scramble?", "Dead end", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (boxResult == DialogResult.Yes) { _field.Scramble(); } } _selected = null; } }
public async Task <bool> AddPlayResult([FromBody] PlayResult playResult) { bool playResultAdded = false; try { playResultAdded = await _sqlServerUow.PlayResults.AddAsync(playResult); } catch (Exception ex) { } return(playResultAdded); }
void Update() { if (_started) { //计时 计算过关所用时间 超过最大时间则显示失败界面 _tick += Time.deltaTime; if (_tick > SceneManager.SceneConfig.star1) { _result = PlayResult.FAIL; StartEating(); } } }
public void Play_ValidMoveName_Win() { //Arrange string moveName = "Rock"; string againstMoveName = "Scissors"; Move newMove = new Move(moveName); newMove.AddKill(againstMoveName); //Act PlayResult result = newMove.Play(againstMoveName); //Assert Assert.AreEqual(PlayResult.Win, result); }
private async Task SendToBothAsync(ChessGameSession session, IPlayer sender, PlayResult result) { var otherPlayer = GetOtherPlayer(session, sender); var msgToSend = new ChessPlayResultMessage() { Message = result.ToString() }; await messageSender.SendMessageAsync(sender.Socket, msgToSend); msgToSend.IsClientTurn = true; await messageSender.SendMessageAsync(otherPlayer.Socket, msgToSend); await SendChessPiecesAndMovesMessageAsync(session); }
private static void MatchSummary(TeamSummary teamSummary, PlayResult matchResult) { teamSummary.Points += 1; if (matchResult.PointsFor <= matchResult.PointsAgainst) { teamSummary.Loses += 1; } else { teamSummary.Wins += 1; teamSummary.Points += 1; } teamSummary.PointsForSum += matchResult.PointsFor; teamSummary.PointsAgainstSum += matchResult.PointsAgainst; }
// This is executed in a new thread each time, so it is safe to use blocking calls protected override void OnIncomingCall(Call call) { AnswerResult resultAnswer = call.Answer(); if (!resultAnswer.Successful) { Completed.Set(); return; } PlayResult resultPlay = call.PlayTTS("I'm a little teapot."); HangupResult resultHangup = call.Hangup(); Successful = resultPlay.Successful && resultHangup.Successful; Completed.Set(); }
/// <summary> /// User plays at this position /// </summary> /// <param name="position">Position where to play, (col,row) 0-based</param> /// <returns>Result of playing at this position</returns> public PlayResult PlayAt(Point position) { PlayResult result = PlayResult.Continue; if (!GameBoard.Dimensions.Contains(position)) { result = PlayResult.Invalid; } else { var marker = GameBoard[position]; if (marker.isShowing) { // Can't play at a position which is already showing its marker result = PlayResult.Invalid; } else { // Reveal this marker marker.isShowing = true; // So did we die?? if (marker.isBomb) { result = PlayResult.GameOver; } else { marker.NumNearbyBombs = CountBombsNear(position); // If this space is empty, recursively play all still-hidden spaces around me if (0 == marker.NumNearbyBombs) { PlayAllNear(position); } if (isVictoryConditionMet()) { result = PlayResult.Victory; } } } } return(result); }
public void Notify(Match match) { countDown--; if (countDown == 0) { current += 2; // get next odd countDown = current; // switch strategy if (strategy == PlayResult.Cooperate) { strategy = PlayResult.Defect; } if (strategy == PlayResult.Defect) { strategy = PlayResult.Cooperate; } } }
unsafe public PlayResult SetOurNextStatement(IStatement statement) { PlayResult result = PlayResult.Success; if (statement is SuggestTrade) { if (((SuggestTrade)statement).Offers.Length > 2 || ((SuggestTrade)statement).Wants.Length > 2) { result = new PlayResult(PlayError.RulesViolation); } // check model owners foreach (ITradeItem offer in ((SuggestTrade)statement).Offers) { if (offer is TeachModel && ((TeachModel)offer).Model.Nation != theEmpire.Us) { result = new PlayResult(PlayError.RulesViolation); } } foreach (ITradeItem want in ((SuggestTrade)statement).Wants) { if (want is TeachModel && ((TeachModel)want).Model.Nation != Opponent) { result = new PlayResult(PlayError.RulesViolation); } } if (result.OK) { fixed(int *tradeData = new int[14]) { ((SuggestTrade)statement).FillRawStream(tradeData); result = theEmpire.TestPlay(statement.Command, 0, tradeData); } } } else { result = theEmpire.TestPlay(statement.Command); } if (result.OK) { ourNextStatement = statement; } return(result); }
public void ProcessPlayAction(PlayAction playAction) { CurrentStickRound.ProcessPlayAction(playAction); if (CurrentStickRound.StickResult != null) { Log.Information(CurrentStickRound.StickResult.ToString()); ConfirmAction?.Invoke(); PlayResult = GetPlayResult(); if (PlayResult == null) { var currentPlayer = CurrentStickRound.StickResult.Winner; var stickRound = new StickRound(PlayerGroupInfo, PlayerHandDictionary, currentPlayer, PlayType); StickRoundList.Add(stickRound); } } return; }
public unsafe PlayResult SetOurNextStatement(IStatement statement) { PlayResult result = PlayResult.Success; if (statement is SuggestTrade trade) { if (trade.Offers.Length > 2 || trade.Wants.Length > 2) { result = new PlayResult(PlayError.RulesViolation); } // check model owners foreach (ITradeItem offer in trade.Offers) { if (offer is TeachModel teachModel && teachModel.Model.Nation != TheEmpire.Us) { result = new PlayResult(PlayError.RulesViolation); } } foreach (ITradeItem want in trade.Wants) { if (want is TeachModel teachModel && teachModel.Model.Nation != Opponent) { result = new PlayResult(PlayError.RulesViolation); } } if (result.OK) { fixed(int *tradeData = trade.Data) { result = TheEmpire.TestPlay(statement.Command, 0, tradeData); } } } else { result = TheEmpire.TestPlay(statement.Command); } if (result.OK) { OurNextStatement = statement; } return(result); }
public void Clone_CompleteMove_ValidClone() { //Arrange string moveName = "Rock"; string againstMoveName = "Paper"; Move move = new Move(moveName); move.AddKill(againstMoveName); //Act Move clone = (Move)move.Clone(); //Assert PlayResult result = clone.Play(againstMoveName); Assert.AreEqual(move.Name, clone.Name); Assert.AreEqual(move.Play(againstMoveName), clone.Play(againstMoveName)); }
/// <summary> /// Makes a play in the current game. /// </summary> /// <param name="player1MoveName">The player 1's move.</param> /// <param name="player2MoveName">The player 2's move.</param> /// <returns>The name of the player that won the play. /// If there is a Draw, returns empty.</returns> public string Play(string player1MoveName, string player2MoveName) { if (this.HasWinner()) { throw new InvalidOperationException(GameEngineMessages.PlayHasWinnerError); } if ((string.IsNullOrEmpty(player1MoveName)) || (string.IsNullOrEmpty(player2MoveName))) { throw new ArgumentException(GameEngineMessages.PlayEmptyMoveNameError); } Move player1Move = m_rules.GetMove(player1MoveName); PlayResult result = player1Move.Play(player2MoveName); string playWinnerName = string.Empty; switch (result) { case PlayResult.Draw: break; case PlayResult.Win: m_data.ScorePlayer1++; playWinnerName = Player1Name; break; case PlayResult.Lose: m_data.ScorePlayer2++; playWinnerName = Player2Name; break; default: throw new NotSupportedException(GameEngineMessages.PlayResultNotSupported); } if (HasWinner()) { m_data.WinnerName = playWinnerName; } m_data.LastPlayWinnerName = playWinnerName; return(playWinnerName); }
/// <summary> /// 吃到草莓,显示过关结果。 /// </summary> /// <param name="other"></param> void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player" && _result != PlayResult.FAIL) { Pause(); if (_tick <= SceneManager.SceneConfig.star3) { _result = PlayResult.STAR3; } else if (_tick <= SceneManager.SceneConfig.star2) { _result = PlayResult.STAR2; } else { _result = PlayResult.STAR1; } this.gameObject.SetActive(false); ShowResult(); } }
public void Initialize() { current = 1; countDown = 1; strategy = PlayResult.Cooperate; }