예제 #1
0
 public void Check(TimeStat Time)
 {
     if (Count < 0)
     {
         if (handler == null)
         {
             UIControls.Win = new NavigationWindow();
             handler        = new DisplayHandler(CheckLoseEvent);
             resultObj      = handler.BeginInvoke(Time, new AsyncCallback(AsyncCompleted), null);
         }
     }
 }
예제 #2
0
        protected virtual void FuncStart(Game Game, CancellationToken token, IValuta Price)
        {
            TimeStat daystmp = new TimeStat(Game.User.Times);

            daystmp.AddDate(Time);

            TimeStat daybuf = new TimeStat(Game.User.Times);

            daybuf.AddDays(1);
            while (true)
            {
                if (token.IsCancellationRequested)
                {
                    cts.Dispose();
                    return;
                }
                if (Game.User.Times == daybuf)
                {
                    foreach (var x in Abilities)
                    {
                        x.DoEffect();
                    }

                    daybuf = daybuf = new TimeStat(Game.User.Times);
                    daybuf.AddDays(1);
                }
                if (Game.User.Times == daystmp)
                {
                    if (CheckList != null && CheckList.Count > 0)
                    {
                        foreach (var x in CheckList)
                        {
                            if (x.Check() == false)
                            {
                                cts.Cancel();
                                cts.Dispose();
                                IsPressed = !IsPressed;
                                return;
                            }
                        }
                    }

                    NegativeAbility a = new NegativeAbility(Game.User.Valutes, Price);
                    a.DoEffect();

                    daystmp = new TimeStat(Game.User.Times);
                    daystmp.AddDate(Time);
                }
            }
        }
예제 #3
0
 public User(string Name, TimeStat Times, Valutes Valutes, BottlesStat Bottles, TransportStat Transports, PropertyStat Properties,
             RaitingStat Raiting, StatusStat Status, EducStat Educ, MoodStat Mood, HpStat Hp, FoodStat Food)
     : this(Mood, Hp, Food)
 {
     this.Name       = Name;
     this.Times      = Times;
     this.Valutes    = Valutes;
     this.Bottles    = Bottles;
     this.Transports = Transports;
     this.Properties = Properties;
     this.Raiting    = Raiting;
     this.Status     = Status;
     this.Educ       = Educ;
     Passport        = new PassportStat(false);
     DriverLicense   = new DriverLicenseStat(false);
 }
예제 #4
0
        static void RunServer()
        {
            try
            {
                TimeStat  timeAll         = new TimeStat();
                LockTimer perfUpdateTimer = new LockTimer(60 * 1000);
                perfUpdateTimer.Trigger();

                while (true)
                {
                    timeAll.Start();

                    GameTime.Update();
                    OnTick?.Invoke();

                    GameTime.Update();
                    GUCTimer.Update(GameTime.Ticks); // move to new thread?

                    //Run the dispatcher
                    GUCDispatcher.Execute();


                    GameTime.Update();
                    GameServer.Update(); //process received packets

                    GameTime.Update();
                    WorldObjects.World.ForEach(w => w.OnTick(GameTime.Ticks));

                    long elapsed = timeAll.Stop();
                    if (perfUpdateTimer.IsReady)
                    {
                        Logger.Log("Performance: {0:0}ms avg, {1:0}ms max. RAM: {2:0.0}MB", timeAll.Average, timeAll.Maximum, Process.GetCurrentProcess().PrivateMemorySize64 / 1000000d);
                        timeAll.Reset();
                    }

                    long diff = (updateRate - elapsed) / TimeSpan.TicksPerMillisecond;
                    if (diff > 0)
                    {
                        Thread.Sleep((int)diff);
                    }
                }
            }
            catch (Exception e)
            {
                Logger.LogError(e.Source + "<br>" + e.Message + "<br>" + e.StackTrace);
            }
        }
예제 #5
0
        void CheckLoseEvent(TimeStat Time)
        {
            TimeStat loseday = new TimeStat(Time);

            loseday.AddDate(Settings_.daysDied);
            System.Windows.MessageBox.Show(Settings_.warningMessege);
            while (true)
            {
                if (Count > 0)
                {
                    handler = null;
                    flag    = false;
                    return;
                }
                else if (loseday.Is(Time))
                {
                    System.Windows.MessageBox.Show(DiedMessege);
                    flag = true;
                    return;
                }
            }
        }
예제 #6
0
        public List <TimeStat> Performance(int month, TimePeriod period)
        {
            List <TimeStat> result = new List <TimeStat>();

            try
            {
                using (ISession Session = ConnectionHelper.CreateNewSession())
                {
                    var      rateList = Session.Query <DBRates>().Where(x => x.Retired == false).ToList();
                    DateTime now      = DateTime.Now;
                    int      dayFrom  = 1;
                    int      year     = now.Year;
                    if (now.Month < month + 1)
                    {
                        year--;
                    }

                    DateTime from     = new DateTime(year, month + 1, dayFrom);
                    int      dayTo    = now.Month == month + 1 ? now.Day : DateTime.DaysInMonth(year, month + 1);
                    DateTime to       = new DateTime(year, month + 1, dayTo);
                    var      Accounts = Session.Query <DBAccount>(); // .Where(x => (x.Retired == false));
                    //var Deals = Session.Query<DBDeals>().Where(x => x.Terminal.Demo == false);
                    for (int i = dayFrom; i <= dayTo; i++)
                    {
                        DateTime forDate    = new DateTime(year, month + 1, i);
                        DateTime forDateEnd = new DateTime(year, month + 1, i, 23, 50, 0);
                        TimeStat ts         = new TimeStat();
                        ts.X      = i;
                        ts.Date   = forDate;
                        ts.Period = period;
                        ts.Gains  = 0;
                        ts.Losses = 0;
                        foreach (var acc in Accounts)
                        {
                            if (acc.Terminal != null)
                            {
                                if (acc.Terminal.Demo)
                                {
                                    continue;
                                }
                            }
                            var accStateAll     = Session.Query <DBAccountstate>().Where(x => x.Account.Id == acc.Id);
                            var accResultsStart = accStateAll.Where(x => x.Date <= forDate)
                                                  .OrderByDescending(x => x.Date);
                            var accResultsEnd = accStateAll.Where(x => x.Date <= forDateEnd)
                                                .OrderByDescending(x => x.Date);

                            if (accResultsEnd == null || accResultsEnd.Count() == 0)
                            {
                                continue;
                            }
                            if (accResultsStart == null || accResultsStart.Count() == 0)
                            {
                                continue;
                            }

                            var     accStateEnd  = accResultsEnd.FirstOrDefault();
                            decimal balanceStart = new decimal(0);
                            decimal balanceEnd   = new decimal(0);
                            if (accStateEnd != null)
                            {
                                balanceEnd = ConvertToUSD(accStateEnd.Balance, acc.Currency.Name);
                                if (acc.Typ > 0)
                                {
                                    ts.InvestingValue += balanceEnd;
                                }

                                ts.CheckingValue += balanceEnd;
                            }

                            var accStateStart = accResultsStart.FirstOrDefault();
                            if (accStateStart != null)
                            {
                                balanceStart = ConvertToUSD(accStateStart.Balance, acc.Currency.Name);
                                if (acc.Typ > 0)
                                {
                                    ts.InvestingChange += balanceStart;
                                }

                                ts.CheckingChange += balanceStart;
                            }

                            /*if (balanceStart > balanceEnd)
                             * {
                             *  ts.Losses += (balanceStart - balanceEnd);
                             * }
                             * if (balanceEnd > balanceStart)
                             * {
                             *  ts.Gains += (balanceEnd - balanceStart);
                             * }*/
                        }

                        ts.CheckingChange  = ts.CheckingValue - ts.CheckingChange;
                        ts.InvestingChange = ts.InvestingValue - ts.InvestingChange;
                        if (ts.CheckingChange > 0)
                        {
                            ts.Gains = ts.CheckingChange;
                        }
                        else
                        {
                            ts.Losses = Math.Abs(ts.CheckingChange);
                        }

                        ts.CheckingChange  = Math.Round(ts.CheckingChange, 2);
                        ts.InvestingChange = Math.Round(ts.InvestingChange, 2);
                        ts.CheckingValue   = Math.Round(ts.CheckingValue, 2);
                        ts.InvestingValue  = Math.Round(ts.InvestingValue, 2);
                        ts.Losses          = Math.Round(ts.Losses, 2);
                        ts.Gains           = Math.Round(ts.Gains, 2);

                        result.Add(ts);
                    }
                }
            }
            catch (Exception e)
            {
                log.Error("Error in Performance : " + e);
            }

            return(result);
        }
예제 #7
0
 public EnableSubscribeEvent(Button Button, TimeStat time, List <IAbility> abilities) : base(Button, abilities, time)
 {
 }
예제 #8
0
 public SubscribeEvent(Button Button, List <CheckAbility> CheckList, List <IAbility> abilities, TimeStat time)
     : base(Button, CheckList, abilities)
 {
     IsPressed = false;
     Time      = time;
 }
예제 #9
0
 public SubscribeEvent() : base()
 {
     IsPressed = false;
     Time      = null;
 }
예제 #10
0
 public void Check(TimeStat Time)
 {
     UAH.Check(Time);
     USD.Check(Time);
 }