Ejemplo n.º 1
0
        /* Queries:
         *  do_login (bool) - Not Guest (?)
         *  game_net_user_id (int) - ?
         *  ignore (int) - ?
         *  game_net (string) - ?
         *  guid (string) - Account E-mail
         *  play_platform (string) - ?
         *  password (string) - Account Password
         *  gameClientVersion (string) - Client Version
         */

        protected override void HandleRequest()
        {
            DbAccount acc;

            var status = Database.Verify(Query["guid"], Query["password"], out acc);

            if (!(status == LoginStatus.OK))
            {
                WriteLine("<Error>Account not found</Error>");
                return;
            }

            if (MonthCalendarUtils.DISABLE_CALENDAR || DateTime.UtcNow >= MonthCalendarUtils.EndDate)
            {
                WriteLine("<Error>This feature is disabled.</Error>");
                return;
            }

            var CalendarDb = new DailyCalendar(acc);

            if (CalendarDb.IsNull || MonthCalendarUtils.IsNextCalendar(CalendarDb.LastTime))
            {
                CalendarDb = new DailyCalendar(acc)
                {
                    ClaimedDays        = new int[] { },
                    ConsecutiveDays    = 1,
                    NonConsecutiveDays = 1,
                    UnlockableDays     = 1,
                    LastTime           = DateTime.Today
                };
            }

            if (MonthCalendarUtils.IsNextDay(CalendarDb.LastTime))
            {
                CalendarDb.NonConsecutiveDays++;
                CalendarDb.UnlockableDays++;
                CalendarDb.LastTime = DateTime.Today;
            }

            CalendarDb.FlushAsync();

            WriteLine(GetXML(CalendarDb));
        }