Ejemplo n.º 1
0
 public static void Tactic(string teamName, Tactics tactic)
 {
     Console.WriteLine();
     Console.ForegroundColor = ConsoleColor.DarkYellow;
     Console.WriteLine($"Команда {teamName} выбрала тактику {tactic}");
     Console.ResetColor();
 }
 public HistoryMajor()
 {
     health       = 22; maxHP = 22; strength = 4; power = 0; charge = 0; defense = 0; guard = 0;
     baseAccuracy = 11; accuracy = 11; dexterity = 1; evasion = 0; type = "History Major"; passive = new Armored(this);
     quirk        = Quirk.GetQuirk(this); special = new Joust(); special2 = new Tactics();
     player       = false; champion = false; recruitable = true; CreateDrops(); attackEffect = "gain 1 guard";
 }
Ejemplo n.º 3
0
        public Club(
            int id,
            int lp,
            string name,
            string city,
            string league,
            int money,
            Tactics tactics,
            StatisticsClub statistics)
        {
            this.id        = id;
            this.ordinalNr = lp;
            this.name      = name;
            this.city      = city;
            fullName       = name + " " + city;
            this.league    = league;

            this.tactics         = tactics;
            this.statistics      = statistics;
            this.statistics.club = this;

            squad   = new Squad(this);
            stadium = new Stadium(this, 4000);
            finance = new Finance(this, money);
        }
Ejemplo n.º 4
0
 public void ProcessHitResult(HitResults hitResult)
 {
     if (hitResult == HitResults.Hit)
     {
         m_squaresHit.Add(m_lastTarget);
         if (m_tacticsState == Tactics.Random)
         {
             m_tactics = new AfterFirstHitFiring(m_enemyGrid, m_squaresHit[0], m_shipsLeft[0]);
             m_tacticsState = Tactics.AfterFirst;
         }
         else if (m_tacticsState == Tactics.AfterFirst)
         {
             m_tactics = new OrientationalFiring(m_enemyGrid, m_squaresHit.ToArray(), m_shipsLeft[0]);
             m_tacticsState = Tactics.Orientational;
         }
         else
         {
             m_tactics.AddNewHit(m_lastTarget);
         }
     }
     else if (hitResult == HitResults.Sunk)
     {
         m_squaresHit.Add(m_lastTarget);
         m_squaresHit.Sort(((sq1, sq2) => sq1.Row == sq2.Row ? sq1.Column - sq2.Column : sq1.Row - sq2.Row));
         m_enemyGrid.OccupySquares(m_squaresHit.ToArray());
         int shipLength = m_squaresHit.Count;
         m_shipsLeft.Remove(shipLength);
         if (AnyShipLeft())
         {
             m_squaresHit.Clear();
             m_tactics = new RandomFiring(m_enemyGrid, m_shipsLeft[0]);
             m_tacticsState = Tactics.Random;
         }
     }
 }
Ejemplo n.º 5
0
 public Gunnary()
 {
     m_enemyGrid = new EnemyGrid();
     m_tactics = new RandomFiring(m_enemyGrid, Fleet.ShipLengths[0]);
     m_tacticsState = Tactics.Random;
     m_squaresHit = new List<Square>();
     m_shipsLeft = new List<int>(Fleet.ShipLengths);
 }
Ejemplo n.º 6
0
 public RectangleGFRRT(State xinit, InfoDomain domain, int maxiter, Validator validator, Tactics tactics)
 {
     this._xinit     = xinit;
     this._domain    = domain;
     this._maxiter   = maxiter;
     this._tactics   = tactics;
     this._validator = validator;
 }
Ejemplo n.º 7
0
 public Player( )
 {
     PAccount    = new AccountInfo();
     PBalance    = new BalanceInfo();
     PEnergy     = new EnergyInfo();
     PCharacters = new CharacterInfo();
     PTactis     = new Tactics();
 }
Ejemplo n.º 8
0
        private Rectangle GetRect(Team tm, Tactics t, Amplua a)
        {
            var rcf = GetFieldRect();

            var i = 0;

            for (var ii = 0; ii < tm.Tactics.Count; ii++)
            {
                if (tm.Tactics[ii] == t)
                {
                    i = ii;
                }
            }

            var index = Game.Match.Team2 == tm ? 1 : 0;

            if (a.Id == 1)
            {
                if (i == 1 || i == 2)
                {
                    var resgk = new Rectangle(0, (int)rcf.Top + GetGkBottom(), (int)rcf.Width / 2, PlaceSize);
                    if (index == 0)
                    {
                        resgk.Offset((int)rcf.Left + (int)(rcf.Width / 2 * (2 - i)), 0);
                    }
                    else
                    {
                        resgk.Offset((int)rcf.Left + (int)(rcf.Width / 2 * (i - 1)), 0);
                    }
                    return(resgk);
                }

                return(Rectangle.Empty);
            }

            var rct = GetRect(tm, t);

            rct = new Rectangle(rct.Left, rct.Top, rct.Width, rct.Height - 20);

            if (i == 0)
            {
                return(Rectangle.Empty);
            }

            if (index == 0)
            {
                var res = new Rectangle((int)rct.Left + (a.Id == 3 ? rct.Width / 2 : 0),
                                        (int)rct.Top, (int)rct.Width / 2, (int)rct.Height);
                return(res);
            }
            else
            {
                var res = new Rectangle((int)rct.Left + (a.Id == 2 ? rct.Width / 2 : 0),
                                        (int)rct.Top, (int)rct.Width / 2, (int)rct.Height);
                return(res);
            }
        }
Ejemplo n.º 9
0
        //通过id获取股东所有的股票持仓记录
        public List <Hold_Stock_Info> getHoldStockInfoById(int id)
        {
            string sql = "select * from t_hold_stock_info as h left join t_tactics as t on h.id = t.hold_stock_info_id where h.stock_holder_id = @id and h.type = 1 order by h.profit_loss desc;";
            List <MySqlParameter> Paramter = new List <MySqlParameter>();

            Paramter.Add(new MySqlParameter("@id", id));

            DataTable dt = DBHelperSQL.Ins.ExcuteDataTable(sql, Paramter.ToArray());

            if (dt.Rows.Count > 0)
            {
                List <Hold_Stock_Info> list = (List <Hold_Stock_Info>) DataConvert <Hold_Stock_Info> .ToList(dt);

                //查询出股票策略
                for (int i = 0; i < list.Count; i++)
                {
                    Tactics tactics = new Tactics();
                    if (dt.Rows[i][14] != DBNull.Value)
                    {
                        tactics.loss_per = Convert.ToDouble(dt.Rows[i][14]);
                    }
                    if (dt.Rows[i][15] != DBNull.Value)
                    {
                        tactics.loss_quantity = int.Parse(dt.Rows[i][15].ToString());
                    }
                    if (dt.Rows[i][16] != DBNull.Value)
                    {
                        tactics.loss_tactics = int.Parse(dt.Rows[i][16].ToString());
                    }
                    if (dt.Rows[i][17] != DBNull.Value)
                    {
                        tactics.profit_per = double.Parse(dt.Rows[i][17].ToString());
                    }
                    if (dt.Rows[i][18] != DBNull.Value)
                    {
                        tactics.profit_quantity = int.Parse(dt.Rows[i][18].ToString());
                    }
                    if (dt.Rows[i][19] != DBNull.Value)
                    {
                        tactics.profit_tactics = int.Parse(dt.Rows[i][19].ToString());
                    }
                    list[i].tactics = tactics;
                }
                //查询出股票的委托记录
                //TODO

                return(list);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 10
0
        private void btn_submit2_Click(object sender, EventArgs e)
        {
            //止损验证
            this.loss_per      = Convert.ToDouble(this.numericUpDown_loss_per.Value);
            this.loss_quantity = Convert.ToInt32(this.numericUpDown_loss_quantity.Value);
            if ((loss_tactics == 1 || loss_tactics == 2) && loss_per <= 0)
            {
                MessageBox.Show("请设置止损百分比!");
                return;
            }
            if ((loss_tactics == 1 || loss_tactics == 2) && loss_quantity % 100 != 0)
            {
                MessageBox.Show("输入的数量应是100的倍数!");
                return;
            }

            //止盈验证
            this.profit_per      = Convert.ToDouble(this.numericUpDown_profit_per.Value);
            this.profit_quantity = Convert.ToInt32(this.numericUpDown_profit_quantity.Value);
            if ((profit_tactics == 1 || profit_tactics == 2) && profit_per <= 0)
            {
                MessageBox.Show("请设置止损百分比!");
                return;
            }
            if ((profit_tactics == 1 || profit_tactics == 2) && profit_quantity % 100 != 0)
            {
                MessageBox.Show("输入的数量应是100的倍数!");
                return;
            }

            if (profit_tactics != 0 || loss_tactics != 0)
            {
                //修改数据库,亏损设置
                Tactics model = new Tactics();
                model.hold_stock_info_id = this.hold_stock_info_id;
                model.loss_per           = this.loss_per;
                model.loss_quantity      = this.loss_quantity;
                model.loss_tactics       = this.loss_tactics;
                model.profit_per         = this.profit_per;
                model.profit_quantity    = this.profit_quantity;
                model.profit_tactics     = this.profit_tactics;
                tacticsService.UpdateTactics(model);


                MessageBox.Show(string.Format("设置成功{0} {1}", this.profit_per.ToString(), this.profit_quantity.ToString()));

                this.DialogResult = DialogResult.OK;
                //关闭窗口
                this.Close();
            }
        }
Ejemplo n.º 11
0
        private void DoMouseMove(object sender, MouseEventArgs e)
        {
            if (Game.Match == null)
            {
                return;
            }

            omPoint = e.Location;

            omTactics = SeekTactics(Team, omPoint);
            omAmplua  = SeekAmplua(omPoint);
            omPlace   = SeekPlace(omPoint);

            gdi.InvalidateRect();
        }
Ejemplo n.º 12
0
        // #NOTE place new DatabaseObjectKind code here

        void InitializeDatabaseInterfaces()
        {
            DamageTypes.SetupDatabaseInterface();
            ImpactEffects.SetupDatabaseInterface();
            WeaponTypes.SetupDatabaseInterface();
            UserClasses.SetupDatabaseInterface();
            Abilities.SetupDatabaseInterface();
            Objects.SetupDatabaseInterface();
            Squads.SetupDatabaseInterface();
            Tactics.SetupDatabaseInterface();
            Techs.SetupDatabaseInterface();
            TerrainTileTypes.SetupDatabaseInterface();
            Powers.SetupDatabaseInterface();
            Civs.SetupDatabaseInterface();
            Leaders.SetupDatabaseInterface();
        }
Ejemplo n.º 13
0
        //添加数据库的规则
        public void AddTactics(Tactics model)
        {
            string sql = "INSERT INTO t_tactics (hold_stock_info_id, loss_per, loss_quantity, loss_tactics, profit_per, profit_quantity, profit_tactics) "
                         + " VALUES (@hold_stock_info_id, @loss_per, @loss_quantity, @loss_tactics,@profit_per, @profit_quantity, @profit_tactics) ";

            List <MySqlParameter> Paramter = new List <MySqlParameter>();

            Paramter.Add(new MySqlParameter("@loss_per", model.loss_per));
            Paramter.Add(new MySqlParameter("@loss_quantity", model.loss_quantity));
            Paramter.Add(new MySqlParameter("@loss_tactics", model.loss_tactics));
            Paramter.Add(new MySqlParameter("@profit_per", model.profit_per));
            Paramter.Add(new MySqlParameter("@profit_quantity", model.profit_quantity));
            Paramter.Add(new MySqlParameter("@profit_tactics", model.profit_tactics));
            Paramter.Add(new MySqlParameter("@hold_stock_info_id", model.hold_stock_info_id));

            DBHelperSQL.Ins.ExecuteNonquery(sql, Paramter.ToArray());
        }
Ejemplo n.º 14
0
        //更新数据库信息
        public void UpdateTactics(Tactics model)
        {
            string sql = "update t_tactics set "
                         + "loss_per = @loss_per, loss_quantity = @loss_quantity, loss_tactics = @loss_tactics ,"
                         + "profit_per = @profit_per, profit_quantity = @profit_quantity, profit_tactics = @profit_tactics where hold_stock_info_id = @hold_stock_info_id";

            List <MySqlParameter> Paramter = new List <MySqlParameter>();

            Paramter.Add(new MySqlParameter("@loss_per", model.loss_per));
            Paramter.Add(new MySqlParameter("@loss_quantity", model.loss_quantity));
            Paramter.Add(new MySqlParameter("@loss_tactics", model.loss_tactics));
            Paramter.Add(new MySqlParameter("@profit_per", model.profit_per));
            Paramter.Add(new MySqlParameter("@profit_quantity", model.profit_quantity));
            Paramter.Add(new MySqlParameter("@profit_tactics", model.profit_tactics));
            Paramter.Add(new MySqlParameter("@hold_stock_info_id", model.hold_stock_info_id));

            DBHelperSQL.Ins.ExecuteNonquery(sql, Paramter.ToArray());
        }
Ejemplo n.º 15
0
        public Team()
        {
            TeamColorsKind = new Dictionary <int, TeamColors>();
            var game = new HockeyIce(HockeyIce.GameTypeEnum.Euro, HockeyIce.KIND_1);

            for (var i = 0; i < 6; i++)
            {
                var t = game.DefaultTactics.Clone();
                t.Name           = "5ka-" + i.ToString();
                t.NameActionType = i;
                if (i > 2)
                {
                    var p = t.GetPlace(game, 21);
                    t.Places.Remove(p);
                }

                Tactics.Add(i, t);
            }
        }
Ejemplo n.º 16
0
        private Rectangle GetRect(Team tm, Tactics t)
        {
            var rcf = GetFieldRect();

            var index = Game.Match.Team2 == tm ? 1 : 0;

            //
            var dist = 90;

            for (var i = 1; i < tm.Tactics.Count; i++)
            {
                if (tm.Tactics[i] == t)
                {
                    return(new Rectangle((int)rcf.Left, (int)rcf.Top + (dist + 20) * (i - 1), (int)rcf.Width, dist + 10));
                }
            }

            return(Rectangle.Empty);
        }
Ejemplo n.º 17
0
        public string GetName(DatabaseObjectKind kind, int id)
        {
            Contract.Requires <ArgumentOutOfRangeException>(kind != DatabaseObjectKind.None);

            // #NOTE place new DatabaseObjectKind code here

            switch (kind)
            {
            case DatabaseObjectKind.Ability:        return(Abilities.TryGetNameWithUndefined(id));

            case DatabaseObjectKind.Civ:            return(Civs.TryGetNameWithUndefined(id));

            case DatabaseObjectKind.DamageType:     return(DamageTypes.TryGetNameWithUndefined(id));

            case DatabaseObjectKind.ImpactEffect: return(ImpactEffects.TryGetNameWithUndefined(id));

            case DatabaseObjectKind.Leader:         return(Leaders.TryGetNameWithUndefined(id));

            case DatabaseObjectKind.Object:         return(Objects.TryGetNameWithUndefined(id));

            case DatabaseObjectKind.ObjectType:     return(ObjectTypes.TryGetNameWithUndefined(id));

            case DatabaseObjectKind.Power:          return(Powers.TryGetNameWithUndefined(id));

            case DatabaseObjectKind.Squad:          return(Squads.TryGetNameWithUndefined(id));

            case DatabaseObjectKind.Tactic:         return(Tactics.TryGetNameWithUndefined(id));

            case DatabaseObjectKind.Tech:           return(Techs.TryGetNameWithUndefined(id));

            case DatabaseObjectKind.TerrainTileType: return(TerrainTileTypes.TryGetNameWithUndefined(id));

            // TODO: Should just use the Objects DBI AFAICT
            case DatabaseObjectKind.Unit:           return(TryGetNameUnit(id));

            case DatabaseObjectKind.UserClass:      return(UserClasses.TryGetNameWithUndefined(id));

            case DatabaseObjectKind.WeaponType:     return(WeaponTypes.TryGetNameWithUndefined(id));

            default: throw new KSoft.Debug.UnreachableException(kind.ToString());
            }
        }
Ejemplo n.º 18
0
        public List <Marker> GetCurrentTacticsMarker(HockeyIce game, Half half, int time, List <int> tactics_num_list)
        {
            if (tactics_num_list.Count == 0)
            {
                tactics_num_list.AddRange(Tactics.Keys);
            }

            var res = new List <Marker>();

            foreach (var i in tactics_num_list)
            {
                if (!Tactics.ContainsKey(i))
                {
                    continue;
                }

                foreach (var place in Tactics[i].Places)
                {
                    if (place.Player == null && i > 0 && tactics_num_list.Count == Tactics.Count)
                    {
                        continue;
                    }

                    var mk = new Marker(game, 16, place.GetCode() + 100 * i);
                    mk.Half      = half;
                    mk.TimeVideo = time;
                    if (place.Player != null)
                    {
                        mk.Player1 = place.Player;
                        mk.Num     = place.Player.Number;
                    }
                    else
                    {
                        mk.Team1 = this;
                    }
                    res.Add(mk);
                }
            }

            return(res);
        }
Ejemplo n.º 19
0
        private Rectangle GetRect(Team tm, Tactics t, Place p)
        {
            var        rcf = GetFieldRect();
            RectangleF rca = GetRect(tm, t, p.Amplua);

            var dw    = (int)rca.Width;
            var dh    = (int)rca.Height / 3;
            var index = Game.Match.Team2 == tm ? 1 : 0;

            var res = (index == 0)
                ? new Rectangle((int)rca.Left, (int)rca.Top + dh * (p.Position.Id - 1), dw, dh)
                : new Rectangle((int)rca.Left, (int)rca.Top + dh * (3 - p.Position.Id), dw, dh);

            // if ((index == 0 && p.Amplua.Id == 2) || (index == 1 && p.Amplua.Id == 3))
            if (index == 0)
            {
                res = new Rectangle(res.Right - PlaceSize, res.Top + res.Height / 2 - PlaceSize / 2, PlaceSize, PlaceSize);
            }
            else
            {
                res = new Rectangle(res.Left, res.Top + res.Height / 2 - PlaceSize / 2, PlaceSize, PlaceSize);
            }

            if (p.Amplua.Id == 2)
            {
                if ((index == 0 && p.Position.Id == 1) || (index == 1 && p.Position.Id == 3))
                {
                    res.Offset(0, +PlaceSize / 2 - 1);
                }
                else
                {
                    res.Offset(0, -PlaceSize / 2 + 1);
                }
            }

            return(res);
        }
Ejemplo n.º 20
0
    public void RunTactics(string coin, bool isPause = true)
    {
        int    runHelper = AppSetting.Ins.GetInt("RunHelper");
        string item      = coin;

        if (runHelper == 1)
        {
            MATaticsHelper m_helper = new MATaticsHelper();
            m_helper.Init(AppSetting.Ins.GetValue(string.Format("MA_{0}", item)));

            Tactics tactics = new Tactics(string.Format("{0}-USD-SWAP", coin), m_helper);

            if (isPause)
            {
                //默认开启的是暂停状态
                tactics.V_TacticsState = EM_TacticsState.Pause;
            }
            m_TacticsDic[tactics.V_Instrument_id] = tactics;
        }
        else if (runHelper == 2)
        {
            MATaticsHelper2 m_helper = new MATaticsHelper2();
            m_helper.Init(AppSetting.Ins.GetValue(string.Format("MA_{0}", item)));

            Tactics tactics = new Tactics(string.Format("{0}-USD-SWAP", coin), m_helper);

            if (isPause)
            {
                //默认开启的是暂停状态
                tactics.V_TacticsState = EM_TacticsState.Pause;
            }
            m_TacticsDic[tactics.V_Instrument_id] = tactics;
        }
        else if (runHelper == 3)
        {
            EMATaticsHelper m_helper = new EMATaticsHelper();
            m_helper.Init(AppSetting.Ins.GetValue(string.Format("EMA_{0}", item)));

            Tactics tactics = new Tactics(string.Format("{0}-USD-SWAP", coin), m_helper);

            if (isPause)
            {
                //默认开启的是暂停状态
                tactics.V_TacticsState = EM_TacticsState.Pause;
            }
            m_TacticsDic[tactics.V_Instrument_id] = tactics;
        }
        else if (runHelper == 4)
        {
            EMATaticsHelper2 m_helper = new EMATaticsHelper2();
            m_helper.Init(AppSetting.Ins.GetValue(string.Format("EMA2_{0}", item)));

            Tactics tactics = new Tactics(string.Format("{0}-USD-SWAP", coin), m_helper);

            if (isPause)
            {
                //默认开启的是暂停状态
                tactics.V_TacticsState = EM_TacticsState.Pause;
            }
            m_TacticsDic[tactics.V_Instrument_id] = tactics;
        }
        else if (runHelper == 5)
        {
            EMAHelper3 m_helper = new EMAHelper3();
            m_helper.Init(AppSetting.Ins.GetValue(string.Format("EMA3_{0}", item)));

            Tactics tactics = new Tactics(string.Format("{0}-USD-SWAP", coin), m_helper);

            if (isPause)
            {
                //默认开启的是暂停状态
                tactics.V_TacticsState = EM_TacticsState.Pause;
            }
            m_TacticsDic[tactics.V_Instrument_id] = tactics;
        }
        else if (runHelper == 6)
        {
            FourPriceHelper m_helper = new FourPriceHelper();
            m_helper.Init(AppSetting.Ins.GetValue(string.Format("FOUR_{0}", item)));

            Tactics tactics = new Tactics(string.Format("{0}-USD-SWAP", coin), m_helper);

            if (isPause)
            {
                //默认开启的是暂停状态
                tactics.V_TacticsState = EM_TacticsState.Pause;
            }
            m_TacticsDic[tactics.V_Instrument_id] = tactics;
        }
        else if (runHelper == 7)
        {
            TurtleTaticsHelper m_helper = new TurtleTaticsHelper();
            m_helper.Init(AppSetting.Ins.GetValue(string.Format("Turtle_{0}", item)));

            Tactics tactics = new Tactics(string.Format("{0}-USD-SWAP", coin), m_helper);

            if (isPause)
            {
                //默认开启的是暂停状态
                tactics.V_TacticsState = EM_TacticsState.Pause;
            }
            m_TacticsDic[tactics.V_Instrument_id] = tactics;
        }
        else if (runHelper == 8)
        {
            SimpleMAHelper m_helper = new SimpleMAHelper();
            m_helper.Init(AppSetting.Ins.GetValue(string.Format("SMA_{0}", item)));

            Tactics tactics = new Tactics(string.Format("{0}-USD-SWAP", coin), m_helper);

            if (isPause)
            {
                //默认开启的是暂停状态
                tactics.V_TacticsState = EM_TacticsState.Pause;
            }
            m_TacticsDic[tactics.V_Instrument_id] = tactics;
        }
        else if (runHelper == 9)
        {
            MeshHelper m_helper = new MeshHelper();
            m_helper.Init(AppSetting.Ins.GetValue(string.Format("Mesh_{0}", item)));

            Tactics tactics = new Tactics(string.Format("{0}-USD-SWAP", coin), m_helper);

            if (isPause)
            {
                //默认开启的是暂停状态
                tactics.V_TacticsState = EM_TacticsState.Pause;
            }
            m_TacticsDic[tactics.V_Instrument_id] = tactics;
        }
    }
Ejemplo n.º 21
0
        public MainWindow()
        {
            InitializeComponent();
            Logger logger = Logger.Instance;

            //A. Intitalization: Setup Initial componenets
            MessageHandler = new MessageHandler();
            InstrumentManager = new InstrumentManager();
            OrderManager = new OrderManager();
            ibClient = new EWrapperImpl();

            lw = new LogWindow();
            dw = new DataWindow();
            tw = new Tactics();

            logger.Log(string.Format("Logging started at {0}", DateTime.Now));


            //B. Dependancy Injection? :  Componenet Linkages
            ibClient.MessageHandler = MessageHandler;
            MessageHandler.EwarapperImpl = ibClient;
            MessageHandler.MyMainWindow = this;
            MessageHandler.Logwindow = lw;
            MessageHandler.DataWindow = dw;
            MessageHandler.OrderManager = OrderManager;
            MessageHandler.InstrumentManager = InstrumentManager;

            //C. Load External Data
            ///including connection parameters
            InstrumentManager.InstrumentsFromCSV();

            //D. Start Monitoring
            MessageHandler.StartMonitoring();

            //E. Establish Connections
            


            // cbInstruments.DataContext = cm.ActiveContracts;
            foreach (var instrument in InstrumentManager.ActiveContracts)
            {
                cbInstruments.Items.Add(instrument.BBCode);
            }

            //Add lists
            //ObservableCollection<Contract> contractList = new ObservableCollection<Contract>();
            //ObservableCollection<Order> orderList = new ObservableCollection<Order>();
            //ObservableCollection<Execution> tradeList = new ObservableCollection<Execution>();

            //contractList = new ObservableCollection<Contract>(InstrumentManager.ActiveContracts.ToList());
            //orderList = new ObservableCollection<Order>(OrderManager.ActiveOrders.ToList());
            //tradeList = new ObservableCollection<Execution>(OrderManager.Executions.ToList());

            dgOrders.ItemsSource = OrderManager.ActiveOrders.ToList();
            dgContracts.ItemsSource = InstrumentManager.ActiveContracts.ToList();
            dgTrades.ItemsSource = OrderManager.Executions.ToList();

            lw.Show();
            dw.Show();
            tw.Show();



        }
Ejemplo n.º 22
0
    private void RunTAIS(Tactics tactic, Target target)
    {
        Entity tacTarget = GetTacticalTarget(target, playerOwner.unitsList);
        if (isHealer) {
            if (tacTarget == null || (tacTarget.CurrentHitPoints > tacTarget.MaxHitPoints * HealThreshold)) {
                tacTarget = GetMostDamagedUnit(playerOwner.unitsList);
            }

            if (tacTarget != null && (tacTarget.CurrentHitPoints <= tacTarget.MaxHitPoints * HealThreshold)) {
                if (GetIsWithinPerceptionRange(tacTarget)) {
                    healTarget = tacTarget;
                    this.currentUnitState = UnitController.UnitState.HEALING;
                }
            }
        }

        if (!isHealer || (isHealer && healTarget == null)) {
            if (tactic == Tactics.Guard) {
                attackTarget = GuardOther(tacTarget);
            }
            else if (tactic == Tactics.Follow) {
                attackTarget = FollowOther(tacTarget);
            }
            else if (tactic == Tactics.HoldTheLine) {
                attackTarget = StandGround(playerOwner.unitsList);
            }
            else {
                tacTarget = GetTacticalTarget(target, _gameController.enemies);
                if (GetIsWithinPerceptionRange(tacTarget)) {
                    attackTarget = tacTarget;
                }
            }

            // self defense fallback
            if ((attackTarget == null && lastAttacker != null) && GetIsWithinPerceptionRange(lastAttacker)) {
                attackTarget = lastAttacker;
            }
        }
    }
Ejemplo n.º 23
0
 public string GetTacticsTip(Tactics tactic)
 {
     string tip = "";
     switch (tactic) {
         case Tactics.Attack: tip = "Attack: Unit will attack target at will (default behaviour)."; break;
         case Tactics.Guard: tip = "Guard: Unit will attempt to protect target, by attacking any enemy attacking target."; break;
         case Tactics.Follow: tip = "Assist: Unit will attempt to follow and assist target, by attacking the same enemy as target."; break;
         case Tactics.HoldTheLine: tip = "Stand Ground: Unit will attempt to stand ground and not move far from the initial position."; break;
     }
     return tip;
 }
Ejemplo n.º 24
0
 public string GetTacticsName(Tactics tactic)
 {
     string name = "";
     switch (tactic) {
         case Tactics.Attack: name = "Attack"; break;
         case Tactics.Guard: name = "Guard"; break;
         case Tactics.Follow: name = "Assist"; break;
         case Tactics.HoldTheLine: name = "Stand Ground"; break;
     }
     return name;
 }
Ejemplo n.º 25
0
        public List <Tactics> loadTactics(UInt32 id, MemoryStream memory1, BinaryReader reader)
        {
            List <Tactics> list = new List <Tactics>();

            //Calcolo tattiche
            int bytesTactics = (int)memory1.Length;
            int tactics      = bytesTactics / block;

            if (tactics == 0)
            {
                MessageBox.Show("No tactics found", Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
                SplashScreen._SplashScreen.Close();
            }

            UInt32 Team_id;
            UInt16 tactics_id;
            UInt16 Frag_val1;
            UInt16 Frag_val2;
            UInt16 Frag_val3;
            UInt16 Frag_val4;
            UInt16 Frag_val5;
            UInt16 FRAG_VAL;

            reader.BaseStream.Position = 0;
            for (int i = 0; i <= (tactics - 1); i++)
            {
                Team_id = reader.ReadUInt32();
                if (Team_id == id)
                {
                    tactics_id = reader.ReadUInt16();
                    FRAG_VAL   = reader.ReadUInt16();

                    Frag_val1 = (ushort)(FRAG_VAL >> 14); //defendingNumbers
                    Frag_val2 = (ushort)(FRAG_VAL << 2);  //attackingNumbers
                    Frag_val2 = (ushort)(Frag_val2 >> 14);
                    Frag_val3 = (ushort)(FRAG_VAL << 4);  //defensiveLine
                    Frag_val3 = (ushort)(Frag_val3 >> 12);
                    Frag_val4 = (ushort)(FRAG_VAL << 8);  //supportRange
                    Frag_val4 = (ushort)(Frag_val4 >> 12);
                    Frag_val5 = (ushort)(FRAG_VAL << 12); // compactness;
                    Frag_val5 = (ushort)(Frag_val5 >> 12);
                    byte CHECBOXES_VAL = reader.ReadByte();

                    byte CHECK103 = (byte)(CHECBOXES_VAL >> 7);  //buildUp
                    byte CHECK104 = (byte)(CHECBOXES_VAL << 1);  //Defensive Style;
                    CHECK104 = (byte)(CHECK104 >> 7);
                    byte CHECK105 = (byte)(CHECBOXES_VAL << 2);  //Attacking Area
                    CHECK105 = (byte)(CHECK105 >> 7);

                    byte CHECK106 = (byte)(CHECBOXES_VAL << 3);  //Containment Area
                    CHECK106 = (byte)(CHECK106 >> 7);

                    byte CHECK107 = (byte)(CHECBOXES_VAL << 4);  //Pressuring
                    CHECK107 = (byte)(CHECK107 >> 7);

                    byte CHECK108 = (byte)(CHECBOXES_VAL << 5);  //Attacking Style
                    CHECK108 = (byte)(CHECK108 >> 7);

                    byte CHECK109 = (byte)(CHECBOXES_VAL << 6);  //Fluid Formation
                    CHECK109 = (byte)(CHECK109 >> 7);

                    byte CHECK110 = (byte)(CHECBOXES_VAL << 7);  //Positioning
                    CHECK110 = (byte)(CHECK110 >> 7);

                    Tactics temp = new Tactics(Team_id, tactics_id);
                    temp.setDefendingNumbers(Frag_val1);
                    temp.setAttackingNumbers(Frag_val2);
                    temp.setDefensiveLine((ushort)(Frag_val3 + 1));
                    temp.setSupportRange((ushort)(Frag_val4 + 1));
                    temp.setCompactness((ushort)(Frag_val5 + 1));
                    temp.setBuildUp(CHECK103);
                    temp.setDefensiveStyle(CHECK104);
                    temp.setAttackingArea(CHECK105);
                    temp.setContainmentArea(CHECK106);
                    temp.setPressuring(CHECK107);
                    temp.setAttackingStyle(CHECK108);
                    temp.setFluidFormation(CHECK109);
                    temp.setPositioning(CHECK110);
                    list.Add(temp);

                    reader.BaseStream.Position += 3;
                }
                else
                {
                    reader.BaseStream.Position += 8;
                }
            }

            return(list);
        }
Ejemplo n.º 26
0
        public void applyTactics(BinaryReader reader, MemoryStream unzlib, Tactics tattica, ref BinaryWriter writer)
        {
            //Calcolo tattiche
            int bytesTactics = (int)unzlib.Length;
            int tactics      = bytesTactics / block;

            UInt16 Frag_val1;
            UInt16 Frag_val2;
            UInt16 Frag_val3;
            UInt16 Frag_val4;
            UInt16 Frag_val5;
            UInt16 FRAG_VAL = 0;

            long START2 = -8;

            for (int i = 0; i <= (tactics - 1); i++)
            {
                START2 += block;
                unzlib.Seek(START2, SeekOrigin.Begin);
                if (tattica.getTacticsId() == reader.ReadUInt16())
                {
                    writer.BaseStream.Position = START2;
                    Frag_val1 = tattica.getDefendingNumbers();
                    Frag_val2 = tattica.getAttackingNumbers();
                    Frag_val3 = (ushort)(tattica.getDefensiveLine() - 1);
                    Frag_val4 = (ushort)(tattica.getSupportRange() - 1);
                    Frag_val5 = (ushort)(tattica.getCompactness() - 1);
                    UInt16 aux16 = (ushort)(Frag_val1 << 14);
                    FRAG_VAL = (ushort)(aux16 | FRAG_VAL);
                    aux16    = (ushort)(Frag_val2 << 12);
                    FRAG_VAL = (ushort)(aux16 | FRAG_VAL);
                    aux16    = (ushort)(Frag_val3 << 8);
                    FRAG_VAL = (ushort)(aux16 | FRAG_VAL);
                    aux16    = (ushort)(Frag_val4 << 4);
                    FRAG_VAL = (ushort)(aux16 | FRAG_VAL);
                    aux16    = Frag_val5;
                    FRAG_VAL = (ushort)(aux16 | FRAG_VAL);

                    byte CHECK103;
                    if (tattica.getBuildUp() == 1)
                    {
                        CHECK103 = 1;
                    }
                    else
                    {
                        CHECK103 = 0;
                    }

                    byte CHECK104;
                    if (tattica.getDefensiveStyle() == 1)
                    {
                        CHECK104 = 1;
                    }
                    else
                    {
                        CHECK104 = 0;
                    }

                    byte CHECK105;
                    if (tattica.getAttackingArea() == 1)
                    {
                        CHECK105 = 1;
                    }
                    else
                    {
                        CHECK105 = 0;
                    }

                    byte CHECK106;
                    if (tattica.getContainmentArea() == 1)
                    {
                        CHECK106 = 1;
                    }
                    else
                    {
                        CHECK106 = 0;
                    }

                    byte CHECK107;
                    if (tattica.getPressuring() == 1)
                    {
                        CHECK107 = 1;
                    }
                    else
                    {
                        CHECK107 = 0;
                    }

                    byte CHECK108;
                    if (tattica.getAttackingStyle() == 1)
                    {
                        CHECK108 = 1;
                    }
                    else
                    {
                        CHECK108 = 0;
                    }

                    byte CHECK109;
                    if (tattica.getFluidFormation() == 1)
                    {
                        CHECK109 = 1;
                    }
                    else
                    {
                        CHECK109 = 0;
                    }

                    byte CHECK110;
                    if (tattica.getPositioning() == 1)
                    {
                        CHECK110 = 1;
                    }
                    else
                    {
                        CHECK110 = 0;
                    }

                    byte AuxByte   = (byte)(CHECK103 << 7);
                    byte Byte_GRAB = 0;
                    Byte_GRAB = (byte)(AuxByte | Byte_GRAB);
                    AuxByte   = (byte)(CHECK104 << 6);
                    Byte_GRAB = (byte)(AuxByte | Byte_GRAB);
                    AuxByte   = (byte)(CHECK105 << 5);
                    Byte_GRAB = (byte)(AuxByte | Byte_GRAB);
                    AuxByte   = (byte)(CHECK106 << 4);
                    Byte_GRAB = (byte)(AuxByte | Byte_GRAB);
                    AuxByte   = (byte)(CHECK107 << 3);
                    Byte_GRAB = (byte)(AuxByte | Byte_GRAB);
                    AuxByte   = (byte)(CHECK108 << 2);
                    Byte_GRAB = (byte)(AuxByte | Byte_GRAB);
                    AuxByte   = (byte)(CHECK109 << 1);
                    Byte_GRAB = (byte)(AuxByte | Byte_GRAB);
                    AuxByte   = CHECK110;
                    Byte_GRAB = (byte)(AuxByte | Byte_GRAB);

                    writer.BaseStream.Position += 2;
                    writer.Write(FRAG_VAL);
                    writer.Write(Byte_GRAB);
                }
            }
        }
Ejemplo n.º 27
0
        //更新界面信息
        private void display()
        {
            //查询股票投资策略信息
            Tactics info = tacticsService.getTacticsById(hold_stock_info_id);

            if (info != null)
            {
                this.numericUpDown_loss_per.Value = Convert.ToDecimal(info.loss_per);
                if (info.loss_quantity == 0)
                {
                    this.numericUpDown_loss_quantity.Value = 100;
                }
                else
                {
                    this.numericUpDown_loss_quantity.Value = info.loss_quantity;
                }

                switch (info.loss_tactics)
                {
                case 1:
                    this.rb_1_1.Select();
                    break;

                case 2:
                    this.rb_1_2.Select();
                    break;

                case 3:
                    this.rb_1_3.Select();
                    break;

                case 4:
                    this.rb_1_4.Select();
                    break;

                case 5:
                    this.rb_1_5.Select();
                    break;

                case 6:
                    this.rb_1_6.Select();
                    break;

                case -1:
                    this.rb_1_0.Select();
                    break;

                default:
                    break;
                }

                this.numericUpDown_profit_per.Value = Convert.ToDecimal(info.profit_per);
                if (info.profit_quantity == 0)
                {
                    this.numericUpDown_profit_quantity.Value = 100;
                }
                else
                {
                    this.numericUpDown_profit_quantity.Value = info.profit_quantity;
                }

                switch (info.profit_tactics)
                {
                case 1:
                    this.rb_2_1.Select();
                    break;

                case 2:
                    this.rb_2_2.Select();
                    break;

                case 3:
                    this.rb_2_3.Select();
                    break;

                case 4:
                    this.rb_2_4.Select();
                    break;

                case 5:
                    this.rb_2_5.Select();
                    break;

                case 6:
                    this.rb_2_6.Select();
                    break;

                case -1:
                    this.rb_2_0.Select();
                    break;

                default:
                    break;
                }
            }
        }