Esempio n. 1
0
 public GameMenu(
     SysDriver sys,
     string gameFileName,
     InitialGameMode mode = InitialGameMode.Menu)
     : base(sys)
 {
     _gameFileName = gameFileName;
     _mode         = mode;
 }
Esempio n. 2
0
 public GameRuntime(SysDriver api) : base(api)
 {
 }
Esempio n. 3
0
 public CreateGame(SysDriver api) : base(api)
 {
 }
Esempio n. 4
0
        /// <summary>
        /// Checks wheteher the user has the paermission to use the page and if so, ensures tat the page is not locked due to architecture
        /// modification in progess. Otherwise, redirects the user to the lockout page with an explanation message.
        /// </summary>
        private void LockingAccess()    // neccessary for each postback (?)
        {
            if (user == null)
            {
                Response.RedirectToRoute("LockoutRoute", new { message = 0 });
                Response.End();
            }

            List <object> usersOnline = GetUsersOnline();

            SysDriver.RemoveForsakenLocks(usersOnline);
            object userId = user.ProviderUserKey;

            int globalRights = SysDriver.GetUserRights(userId, null);
            int localRights  = SysDriver.GetUserRights(userId, CE.project.Id);

            // totalRights are the maximum from local and global rights, counting by digits
            int totalRights = 0;
            int multiply    = 1;

            for (int i = 0; i < 4; i++)
            {
                totalRights  += Math.Max(localRights % 10, globalRights % 10) * multiply;
                localRights  /= 10;
                globalRights /= 10;
                multiply     *= 10;
            }

            // projects management - access rights 10000+ - one such user per application instance, created during installation
            bool projects  = globalRights >= 10000;
            bool users     = totalRights % 10000 >= 1000;
            bool architect = totalRights % 1000 >= 100;
            bool admin     = totalRights % 100 >= 10;

            // release my locks if not in the architect context
            if (CE.GlobalState != GlobalState.Architect)
            {
                SysDriver.ReleaseLock(userId, CE.project.Id, LockTypes.AdminLock);
                SysDriver.ReleaseLock(userId, CE.project.Id, LockTypes.ArchitectLock);
            }

            SysDriver.ReleaseLocksExceptProject(userId, CE.project.Id);

            int errMsg = 0;

            switch (CE.GlobalState)
            {
            case GlobalState.Architect:
                if (!architect)
                {
                    errMsg = 3;
                }
                break;

            case GlobalState.Administer:
                if (!admin)
                {
                    errMsg = 4;
                }
                break;

            case GlobalState.UsersManagement:
                if (!users)
                {
                    errMsg = 5;
                }
                break;

            case GlobalState.ProjectsManagement:
                if (!projects)
                {
                    errMsg = 6;
                }
                break;

            case GlobalState.Account:
                break;

            case GlobalState.Error:
                break;

            default:
                break;
            }
            if (errMsg != 0 && CE.GlobalState != GlobalState.Error)
            {
                Response.RedirectToRoute("LockoutRoute", new { message = errMsg });
            }

            // architect must get both architect and administer lock
            if (CE.GlobalState == GlobalState.Architect)
            {
                if (!SysDriver.TryGetLock(userId, CE.project.Id, LockTypes.ArchitectLock) ||
                    !SysDriver.TryGetLock(userId, CE.project.Id, LockTypes.AdminLock))
                {
                    Response.RedirectToRoute("LockoutRoute", new
                    {
                        message = 2
                    });
                }
            }
            // adminin checks the lock
            else if (CE.GlobalState == GlobalState.Administer && SysDriver.LockOwner(CE.project.Id, LockTypes.AdminLock) != null)
            {
                Response.RedirectToRoute("LockoutRoute", new
                {
                    message = 1
                });
            }
        }
Esempio n. 5
0
 public EditGame(SysDriver sys) : base(sys)
 {
 }
Esempio n. 6
0
 public FantasyConsole()
 {
     Mem           = new Memory(DisplayWidth, DisplayHeight);
     Sys           = new SysDriver(this);
     _programStack = new Stack <Program>();
 }
Esempio n. 7
0
 public RootMenu(SysDriver api) : base(api)
 {
 }
Esempio n. 8
0
 public Program(SysDriver api)
 {
     Sys = api;
 }
Esempio n. 9
0
 public GameDriver(SysDriver sys, Memory mem)
 {
     _engine = Python.CreateEngine();
     _sys    = sys;
     _mem    = mem;
 }