Code Search for Developers
 
 
  

SkunkworkUtils.java from Riot in Emerald city at Krugle


Show SkunkworkUtils.java syntax highlighted

/*
 * Copyright (C) 2001-2005 Pleasant nightmare studio
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
package skunkworks;

import org.pleasantnightmare.riotinecity.it.Hardware;
import org.pleasantnightmare.riotinecity.it.HardwareBuilder;
import org.pleasantnightmare.riotinecity.it.HelpFileMounter;
import org.pleasantnightmare.riotinecity.it.daemons.RouteQueryDaemon;
import org.pleasantnightmare.riotinecity.it.daemons.ShellDaemon;
import org.pleasantnightmare.riotinecity.it.daemons.WwwDaemon;
import org.pleasantnightmare.riotinecity.it.executables.*;
import org.pleasantnightmare.riotinecity.it.filetypes.DaemonFile;
import org.pleasantnightmare.riotinecity.it.filetypes.ExecutableFile;
import org.pleasantnightmare.riotinecity.it.filetypes.Folder;
import org.pleasantnightmare.riotinecity.it.filetypes.TextFile;
import org.pleasantnightmare.riotinecity.it.os.*;
import org.pleasantnightmare.riotinecity.it.os.permissions.RootPermission;
import org.pleasantnightmare.riotinecity.model.Account;
import org.pleasantnightmare.riotinecity.model.AtmModel;

/**
 * Helds factory methods for easy creation of many objects used through
 * testing.
 *
 * @author deus
 * @version 1.0
 * @since Mar 1, 2007 7:18:05 PM
 */
public final class SkunkworkUtils {
    private SkunkworkUtils() {
    }

    public static AtmModel createAtmModel() {
        AtmModel model = new AtmModel(10000);
        model.add(new Account("1234", "Pajo", 2000));
        model.add(new Account("4321", "Deus", 500));
        model.add(new Account("0000", "Shivesh", 4032));
        model.add(new Account("4332", "Zoya", 410998));
        model.add(new Account("4332", "Deva", 32141));
        return model;
    }

    public static void mountRootBinFolder(StorageService storageService) {
        Folder binFolder = new Folder("bin");
        binFolder.add(ExecutableFile.createFromExecutableClass(Connect.class));
        binFolder.add(ExecutableFile.createFromExecutableClass(DaemonRunner.class));
        binFolder.add(ExecutableFile.createFromExecutableClass(Ping.class));
        binFolder.add(ExecutableFile.createFromExecutableClass(Ls.class));
        binFolder.add(ExecutableFile.createFromExecutableClass(Cat.class));
        binFolder.add(ExecutableFile.createFromExecutableClass(Ps.class));
        binFolder.add(ExecutableFile.createFromExecutableClass(Route.class));
        binFolder.add(ExecutableFile.createFromExecutableClass(Traceroute.class));
        binFolder.add(ExecutableFile.createFromExecutableClass(Who.class));
        binFolder.add(ExecutableFile.createFromExecutableClass(Www.class));
        storageService.mountToRoot(binFolder);
    }

    public static void mountRootDaemonFolder(StorageService storageService) {
        Folder daemonFolder = new Folder("services");
        daemonFolder.add(DaemonFile.createFromDaemonClass(WwwDaemon.class));
        daemonFolder.add(DaemonFile.createFromDaemonClass(ShellDaemon.class));
        daemonFolder.add(DaemonFile.createFromDaemonClass(RouteQueryDaemon.class));
        storageService.mountToRoot(daemonFolder);
    }

    public static void mountRootDataFolder(StorageService storageService) {
        Folder dataFolder = new Folder("data");
        dataFolder.add(new TextFile("text1", "Hello world from first text file."));
        dataFolder.add(new TextFile("text2", "Bitchin..."));
        dataFolder.add(new TextFile("text3", "Some text he he he"));
        storageService.mountToRoot(dataFolder);
    }

    public static void mountHelp(StorageService storageService) {
        Folder usrFolder;
        try {
            usrFolder = (Folder) storageService.getByPath("/usr");
        } catch (OperatingSystemError operatingSystemError) {
            usrFolder = new Folder("usr");
            storageService.mountToRoot(usrFolder);
        }
        usrFolder.add(HelpFileMounter.instance().buildHelpFolder());
    }

    public static OperatingSystem createTestOperatingSystem() {
        PlayerOperatingSystem pos = new PlayerOperatingSystem();
        try {
            addTestUsers((UserService) pos.getService(KernelService.KS_USER));
            addFilesAndPrograms((StorageService) pos.getService(KernelService.KS_STORAGE));
        } catch (OperatingSystemError operatingSystemError) {
            throw new RuntimeException(operatingSystemError);
        }
        return pos;
    }

    private static void addFilesAndPrograms(StorageService storageService) {
        mountHelp(storageService);
        mountRootBinFolder(storageService);
        mountRootDaemonFolder(storageService);
        mountRootDataFolder(storageService);
    }

    public static void addTestUsers(UserService us) {
        try {
            us.registerUser("admin", "god", "Administrator");
            us.addPermission("admin", new RootPermission());

            us.registerUser("izezelic", "izezelic", "Ivica Zezelic");
            us.addPermission("izezelic", new RootPermission());

            us.registerUser("gbrencic", "gbrencic", "Goran Brencic");
            us.addPermission("gbrencic", new RootPermission());
        } catch (OperatingSystemError userServiceError) {
            throw new RuntimeException(userServiceError);
        }
    }

    public static Hardware createPlayerComputer(OperatingSystem os) {
        return HardwareBuilder.createComputer(os);
    }
}




See more files for this project here

Riot in Emerald city

Cyberpunk third-person 2100. noir RPG thriller using JMonkey. Its going to be mix between Bloodnet, Neuromancer, DeusEx in gameplay, with pieces of Uplink and many other mini-games for dealing with variety of tasks (lockpicking, hacking...)

Project homepage: http://sourceforge.net/projects/riot-in-ecity
Programming language(s): Java,XML
License: other

  computer/
    NetworkingTest.java
    ShellTest.java
    StorageBuilderTest.java
    StorageParserTest.java
    UserBuilderTest.java
  coned/
    ConceptFrameTest.java
    DeserializerTest.java
    SerializerTest.java
    SerializingTestsCommons.java
    SimpleWrite.java
  juryrig/
    BombEntity.java
    Digipad.java
    Explosive.java
    MakingOfProximityBomb.java
    ShortrangeUltrasonicRadar.java
  room/
    OurGameRoomDoors.java
  ActionMenuTest.java
  ActionMenuTestGame.java
  ActionQuadTest.java
  ApartmentBuilderTest.java
  ArgSplit.java
  AtmDigipadTest.java
  AtmTest.java
  BoundaryBoxViewport.java
  CamerasInRoomSimpleGame.java
  ColladaAnimation.java
  ComputerTest.java
  ConsoleGameTest.java
  DummyAction.java
  InputHandling.java
  InteractionTest.java
  InventoryTest.java
  Md5Animation.java
  ModelLoading3ds.java
  ScreenTest.java
  SkunkworkUtils.java
  SquareRoomTest.java
  TelescreenTest.java
  TestColladaLoading.java
  TexturedBox.java
  ZOrderTest.java