コード例 #1
0
 @SuppressWarnings("unchecked")
 public static void updateContainerDirections(MinecartManiaStorageCart minecart) {
   ArrayList<ItemContainer> containers =
       (ArrayList<ItemContainer>) minecart.getDataValue("ItemContainerList");
   if (containers != null) {
     for (ItemContainer container : containers) {
       container.addDirection(minecart.getDirectionOfMotion());
     }
   }
 }
コード例 #2
0
 @SuppressWarnings("unchecked")
 public static void processItemContainer(MinecartManiaStorageCart minecart) {
   ArrayList<ItemContainer> containers =
       (ArrayList<ItemContainer>) minecart.getDataValue("ItemContainerList");
   if (containers != null) {
     for (ItemContainer container : containers) {
       container.doCollection(minecart);
     }
   }
 }
コード例 #3
0
ファイル: SolGame.java プロジェクト: Rulasmur/DestinationSol
  public void beforeHeroDeath() {
    if (myHero == null) return;

    float money = myHero.getMoney();
    ItemContainer ic = myHero.getItemContainer();

    setRespawnState(money, ic, myHero.getHull().config);

    myHero.setMoney(money - myRespawnMoney);
    for (SolItem item : myRespawnItems) {
      ic.remove(item);
    }
  }
コード例 #4
0
  /** Simple test to confirm containers and joins can be added successfully to a query. */
  public void testContainersAndJoinsAddToQuery() throws Exception {
    Query query = new QueryImpl(new StubDatabaseMapping());
    ItemContainer container1 = new ItemContainer("Table 1");
    StringItem item1 = new StringItem("Column 1");
    container1.addItem(item1);
    query.addTable(container1);

    ItemContainer container2 = new ItemContainer("Table 2");
    StringItem item2 = new StringItem("Column 2");
    container2.addItem(item2);
    query.addTable(container2);

    ItemContainer container3 = new ItemContainer("Table 3");
    StringItem item3 = new StringItem("Column 3");
    container3.addItem(item3);
    query.addTable(container3);

    SQLJoin join1to2 = new SQLJoin(item1, item2);
    SQLJoin join2to3 = new SQLJoin(item2, item3);
    query.addJoin(join1to2);
    query.addJoin(join2to3);

    assertEquals(3, query.getFromTableList().size());
    assertTrue(query.getFromTableList().contains(container1));
    assertTrue(query.getFromTableList().contains(container2));
    assertTrue(query.getFromTableList().contains(container3));
    assertEquals(2, query.getJoins().size());
    assertTrue(query.getJoins().contains(join1to2));
    assertTrue(query.getJoins().contains(join2to3));
  }
コード例 #5
0
ファイル: SolGame.java プロジェクト: Rulasmur/DestinationSol
  // uh, this needs refactoring
  private void createPlayer(ShipConfig prevShip) {
    Vector2 pos = myGalaxyFiller.getPlayerSpawnPos(this);
    myCam.setPos(pos);

    Pilot pilot;
    if (myCmp.getOptions().controlType == GameOptions.CONTROL_MOUSE) {
      myBeaconHandler.init(this, pos);
      pilot =
          new AiPilot(
              new BeaconDestProvider(), true, Fraction.LAANI, false, "you", Const.AI_DET_DIST);
    } else {
      pilot = new UiControlledPilot(myScreens.mainScreen);
    }

    ShipConfig shipConfig;
    if (DebugOptions.GOD_MODE) {
      shipConfig = myPlayerSpawnConfig.godShipConfig;
    } else if (prevShip != null) {
      shipConfig = prevShip;
    } else {
      shipConfig = myPlayerSpawnConfig.shipConfig;
    }

    float money =
        myRespawnMoney != 0 ? myRespawnMoney : myTutorialManager != null ? 200 : shipConfig.money;

    HullConfig hull = myRespawnHull != null ? myRespawnHull : shipConfig.hull;

    String itemsStr = !myRespawnItems.isEmpty() ? "" : shipConfig.items;

    boolean giveAmmo = prevShip == null && myRespawnItems.isEmpty();
    myHero =
        myShipBuilder
            .buildNewFar(
                this,
                new Vector2(pos),
                null,
                0,
                0,
                pilot,
                itemsStr,
                hull,
                null,
                true,
                money,
                null,
                giveAmmo)
            .toObj(this);

    ItemContainer ic = myHero.getItemContainer();
    if (!myRespawnItems.isEmpty()) {
      for (int i1 = 0, sz = myRespawnItems.size(); i1 < sz; i1++) {
        SolItem item = myRespawnItems.get(i1);
        ic.add(item);
      }
    } else if (DebugOptions.GOD_MODE) {
      myItemManager.addAllGuns(ic);
    } else if (myTutorialManager != null) {
      for (int i = 0; i < 50; i++) {
        if (ic.groupCount() > 1.5f * Const.ITEM_GROUPS_PER_PAGE) break;
        SolItem it = myItemManager.random();
        if (!(it instanceof GunItem) && it.getIcon(this) != null && ic.canAdd(it)) {
          ic.add(it.copy());
        }
      }
    }
    ic.seenAll();
    AiPilot.reEquip(this, myHero);

    myObjectManager.addObjDelayed(myHero);
    myObjectManager.resetDelays();
  }
コード例 #6
0
 @Override
 public void addChildListener(ContainerChildListener l) {
   super.addChildListener(l);
   listeners.add(l);
 }
コード例 #7
0
  /**
   * This test is to ensure that a simple graph of the query will have proper edges and nodes.
   *
   * @throws Exception
   */
  public void testGraphWithThreeTables() throws Exception {
    QueryImpl query = new QueryImpl(new StubDatabaseMapping());
    ItemContainer container1 = new ItemContainer("Table 1");
    StringItem item1 = new StringItem("Column 1");
    container1.addItem(item1);
    query.addTable(container1);

    ItemContainer container2 = new ItemContainer("Table 2");
    StringItem item2 = new StringItem("Column 2");
    container2.addItem(item2);
    query.addTable(container2);

    ItemContainer container3 = new ItemContainer("Table 3");
    StringItem item3 = new StringItem("Column 3");
    container3.addItem(item3);
    query.addTable(container3);

    SQLJoin join1to2 = new SQLJoin(item1, item2);
    SQLJoin join2to3 = new SQLJoin(item2, item3);
    query.addJoin(join1to2);
    query.addJoin(join2to3);

    assertEquals(3, query.getFromTableList().size());
    assertTrue(query.getFromTableList().contains(container1));
    assertTrue(query.getFromTableList().contains(container2));
    assertTrue(query.getFromTableList().contains(container3));
    assertEquals(2, query.getJoins().size());
    assertTrue(query.getJoins().contains(join1to2));
    assertTrue(query.getJoins().contains(join2to3));

    TableJoinGraph tableJoinGraph = query.new TableJoinGraph();

    // Check all containers and joins are in the graph
    assertEquals(3, tableJoinGraph.getNodes().size());
    assertTrue(tableJoinGraph.getNodes().contains(container1));
    assertTrue(tableJoinGraph.getNodes().contains(container2));
    assertTrue(tableJoinGraph.getNodes().contains(container3));
    assertEquals(4, tableJoinGraph.getEdges().size());
    assertTrue(tableJoinGraph.getEdges().contains(join1to2));
    assertTrue(tableJoinGraph.getEdges().contains(join2to3));

    // Check adjacent nodes are correct
    assertEquals(1, tableJoinGraph.getAdjacentNodes(container1).size());
    assertTrue(tableJoinGraph.getAdjacentNodes(container1).contains(container2));

    assertEquals(2, tableJoinGraph.getAdjacentNodes(container2).size());
    assertTrue(tableJoinGraph.getAdjacentNodes(container2).contains(container1));
    assertTrue(tableJoinGraph.getAdjacentNodes(container2).contains(container3));

    assertEquals(1, tableJoinGraph.getAdjacentNodes(container3).size());
    assertTrue(tableJoinGraph.getAdjacentNodes(container3).contains(container2));

    // Check inbound edges are correct
    assertEquals(1, tableJoinGraph.getInboundEdges(container1).size());
    assertTrue(tableJoinGraph.getInboundEdges(container1).contains(join1to2));

    assertEquals(2, tableJoinGraph.getInboundEdges(container2).size());
    assertTrue(tableJoinGraph.getInboundEdges(container2).contains(join1to2));
    assertTrue(tableJoinGraph.getInboundEdges(container2).contains(join2to3));

    assertEquals(1, tableJoinGraph.getInboundEdges(container3).size());
    assertTrue(tableJoinGraph.getInboundEdges(container3).contains(join2to3));

    // Check outbound edges are correct
    assertEquals(1, tableJoinGraph.getOutboundEdges(container1).size());
    assertTrue(tableJoinGraph.getOutboundEdges(container1).contains(join1to2));

    assertEquals(2, tableJoinGraph.getOutboundEdges(container2).size());
    assertTrue(tableJoinGraph.getOutboundEdges(container2).contains(join1to2));
    assertTrue(tableJoinGraph.getOutboundEdges(container2).contains(join2to3));

    assertEquals(1, tableJoinGraph.getOutboundEdges(container3).size());
    assertTrue(tableJoinGraph.getOutboundEdges(container3).contains(join2to3));
  }