public async Task <GameRes> Save(SaveGameReq request) { var result = new GameRes() { GameId = 0, Message = "Something went wrong, please contact administrator." }; try { DynamicParameters parameters = new DynamicParameters(); parameters.Add("@GameId", request.GameId); parameters.Add("@GameName", request.GameName); parameters.Add("@Category", request.Categorys); parameters.Add("@Image", request.Images); parameters.Add("@BrandId", request.BrandId); parameters.Add("@Description", request.Description); parameters.Add("@UserId", request.UserId); result = await SqlMapper.QueryFirstOrDefaultAsync <GameRes>(cnn : connection, sql : "sp_SaveGame", param : parameters, commandType : CommandType.StoredProcedure); return(result); } catch (Exception ex) { return(result); } }
public static GameRes operator-(GameRes r1, GameRes r2) { GameRes temp = new GameRes(); temp.meat = r1.meat - r2.meat; return(temp); }
public WaveStreamImpl(GameRes.SoundInput input) { m_input = input; var format = m_input.Format; m_format = WaveFormat.CreateCustomFormat ((WaveFormatEncoding)format.FormatTag, (int)format.SamplesPerSecond, format.Channels, (int)format.AverageBytesPerSecond, format.BlockAlign, format.BitsPerSample); }
public async Task <GameRes> Delete(int id) { var result = new GameRes() { GameId = 0, Message = "Something went wrong, please contact administrator." }; try { DynamicParameters parameters = new DynamicParameters(); parameters.Add("@GameId", id); result = await SqlMapper.QueryFirstOrDefaultAsync <GameRes>(cnn : connection, sql : "sp_DeleteGame", param : parameters, commandType : CommandType.StoredProcedure); return(result); } catch (Exception ex) { return(result); } }
void handleMsg(ByteArray msg) { ByteArray newMsg = new ByteArray(); byte action = msg.readByte(); switch (action) { case Const.CONNECT: yourLogo = msg.readInt(); yourName = msg.readString(); break; case Const.NEW_TURN: bool isMyTurn = msg.readBool(); newTurn(isMyTurn); break; case Const.UP_CHESS: board.chessUp = msg.readInt(); break; case Const.MOVE_CHESS: int pos = msg.readInt(); board.moveChess(pos); break; case Const.YOUR_TURN://就是轮到我了 whoseTurn = GameState.MY_TURN; break; case Const.END_GAME://有人赢了 isGaming = false; whoseTurn = GameState.NO_TURN; gameRes = (GameRes)msg.readInt();//将以int形式发送过来的比赛结果存入gameRes以供检测 break; case Const.RETRACT_APPLY://收到悔棋申请~则显示提示,如同意则回发悔棋指令 MessageBox.show("您同意您的对手悔棋吗?", "同意", delegate() { newMsg.write(Const.RETRACT_CHESS); sendMsg(newMsg); }, "拒绝", delegate() { newMsg.write(Const.RETRACT_DISAGREE); sendMsg(newMsg); }); break; case Const.RETRACT_CHESS: Global.board.retract(); break; case Const.RETRACT_DISAGREE: MessageBox.show("您的对手不同意您悔棋", "了解", delegate() { }, null, null); break; case Const.DISCONNECT://有人掉线了,或者有人退出了isRunning = false; if (client != null) { client.Close(); client = null; } Global.setSceneOld(GameScenes.WELCOME);//返回欢迎界面 isGaming = isRunning = false; break; } msg.Close(); }
void newTurn(bool isMyTurn) { this.whoseTurn = isMyTurn ? GameState.MY_TURN : GameState.YOUR_TURN; this.gameRes = GameRes.NO_WIN; myColor = isMyTurn; board.reset(); isGaming = true; }