Exemplo n.º 1
0
        public void UpdateStrategy(string robotId, RobotStrategy strategy)
        {
            string strategyJson = JsonConvert.SerializeObject(strategy, new StringEnumConverter());

            using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["RobotsAtWarDB"].ConnectionString))
            {
                var query = $@"
IF EXISTS (SELECT 1 FROM dbo.Strategies WHERE ID_Robot = '{robotId}')
BEGIN
    UPDATE 
        [dbo].[Strategies]
    SET 
        [Strategy] = '{strategyJson}'
    WHERE 
        [ID_Robot] = '{robotId}'
END
ELSE
BEGIN
    INSERT INTO [dbo].[Strategies] (
        [ID_Robot],
        [Strategy])
     VALUES (
        '{robotId}',
        '{strategyJson}'
     )
END";

                db.Execute(query);
            }
        }
Exemplo n.º 2
0
    public void SetRobotStrategy(string robotStrategyName)
    {
        switch (robotStrategyName)
        {
        case "RobotStrategyA":
            this._robotStrategy = new RobotStrategyA(gameObject, target);
            break;

        case "RobotStrategyB":
            this._robotStrategy = new RobotStrategyB(gameObject, target);
            break;

        default:
            this._robotStrategy = new RobotStrategyC(gameObject, target);
            break;
        }
    }
Exemplo n.º 3
0
 public RobotPlayer(DataProvider dataProvider, Side side, RobotStrategy robotStrategy) : base(dataProvider, side, false)
 {
     _robotStrategy = robotStrategy;
 }