Java Code Examples for com.watabou.utils.Bundle#contains()
The following examples show how to use
com.watabou.utils.Bundle#contains() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Wand.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 6 votes |
@Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); usesLeftToID = bundle.getInt( USES_LEFT_TO_ID ); availableUsesToID = bundle.getInt( AVAILABLE_USES ); //pre-0.7.2 saves if (bundle.contains( "unfamiliarity" )){ usesLeftToID = Math.min(10, bundle.getInt( "unfamiliarity" )); availableUsesToID = USES_TO_ID/2f; } curCharges = bundle.getInt( CUR_CHARGES ); curChargeKnown = bundle.getBoolean( CUR_CHARGE_KNOWN ); partialCharge = bundle.getFloat( PARTIALCHARGE ); curseInfusionBonus = bundle.getBoolean(CURSE_INFUSION_BONUS); }
Example 2
Source File: Rankings.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
@Override public void restoreFromBundle( Bundle bundle ) { if (bundle.contains( CAUSE )) { cause = bundle.getClass( CAUSE ); } else { cause = null; } win = bundle.getBoolean( WIN ); score = bundle.getInt( SCORE ); heroClass = HeroClass.restoreInBundle( bundle ); armorTier = bundle.getInt( TIER ); if (bundle.contains(DATA)) gameData = bundle.getBundle(DATA); if (bundle.contains(ID)) gameID = bundle.getString(ID); if (gameID == null) gameID = UUID.randomUUID().toString(); depth = bundle.getInt( DEPTH ); herolevel = bundle.getInt( LEVEL ); }
Example 3
Source File: Generator.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 6 votes |
public static void restoreFromBundle(Bundle bundle) { if (bundle.contains(GENERAL_PROBS)){ float[] probs = bundle.getFloatArray(GENERAL_PROBS); for (int i = 0; i < probs.length; i++){ categoryProbs.put(Category.values()[i], probs[i]); } } else { reset(); } initArtifacts(); for ( Class<?extends Artifact> artifact : bundle.getClassArray(SPAWNED_ARTIFACTS) ){ removeArtifact(artifact); } }
Example 4
Source File: TimekeepersHourglass.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
@Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle(bundle); sandBags = bundle.getInt( SANDBAGS ); //these buffs belong to hourglass, need to handle unbundling within the hourglass class. if (bundle.contains( BUFF )){ Bundle buffBundle = bundle.getBundle( BUFF ); if (buffBundle.contains( timeFreeze.PARTIALTIME )) activeBuff = new timeFreeze(); else activeBuff = new timeStasis(); activeBuff.restoreFromBundle(buffBundle); } }
Example 5
Source File: Weapon.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
@Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); usesLeftToID = bundle.getInt( USES_LEFT_TO_ID ); availableUsesToID = bundle.getInt( AVAILABLE_USES ); enchantment = (Enchantment)bundle.get( ENCHANTMENT ); curseInfusionBonus = bundle.getBoolean( CURSE_INFUSION_BONUS ); //pre-0.7.2 saves if (bundle.contains( "unfamiliarity" )){ usesLeftToID = bundle.getInt( "unfamiliarity" ); availableUsesToID = USES_TO_ID/2f; } augment = bundle.getEnum(AUGMENT, Augment.class); }
Example 6
Source File: ItemStatusHandler.java From remixed-dungeon with GNU General Public License v3.0 | 6 votes |
private void restore( Bundle bundle, Integer[] allImages ) { ArrayList<Integer> imagesLeft = new ArrayList<>(Arrays.asList(allImages)); for (int i=0; i < items.length; i++) { Class<? extends T> item = items[i]; String itemName = item.toString(); if (bundle.contains( itemName + PFX_IMAGE )) { Integer image = bundle.getInt( itemName + PFX_IMAGE ); images.put( item, image ); imagesLeft.remove( image ); if (bundle.getBoolean( itemName + PFX_KNOWN )) { known.add( item ); } } else { int index = Random.Int( imagesLeft.size() ); images.put( item, imagesLeft.get( index ) ); imagesLeft.remove( index ); } } }
Example 7
Source File: Armor.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
@Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle(bundle); usesLeftToID = bundle.getInt( USES_LEFT_TO_ID ); availableUsesToID = bundle.getInt( AVAILABLE_USES ); inscribe((Glyph) bundle.get(GLYPH)); curseInfusionBonus = bundle.getBoolean( CURSE_INFUSION_BONUS ); seal = (BrokenSeal)bundle.get(SEAL); //pre-0.7.2 saves if (bundle.contains( "unfamiliarity" )){ usesLeftToID = bundle.getInt( "unfamiliarity" ); availableUsesToID = USES_TO_ID/2f; } augment = bundle.getEnum(AUGMENT, Augment.class); }
Example 8
Source File: Bee.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); spawn( bundle.getInt( LEVEL ) ); potPos = bundle.getInt( POTPOS ); potHolder = bundle.getInt( POTHOLDER ); if (bundle.contains(ALIGMNENT)) alignment = bundle.getEnum( ALIGMNENT, Alignment.class); }
Example 9
Source File: Necromancer.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override public void restoreFromBundle(Bundle bundle) { super.restoreFromBundle(bundle); summoning = bundle.getBoolean( SUMMONING ); if (bundle.contains(FIRST_SUMMON)) firstSummon = bundle.getBoolean(FIRST_SUMMON); if (summoning){ summoningPos = bundle.getInt( SUMMONING_POS ); } if (bundle.contains( MY_SKELETON )){ storedSkeletonID = bundle.getInt( MY_SKELETON ); } }
Example 10
Source File: Blandfruit.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override public void restoreFromBundle(Bundle bundle) { super.restoreFromBundle(bundle); if (bundle.contains(POTIONATTRIB)) { imbuePotion((Potion) bundle.get(POTIONATTRIB)); } }
Example 11
Source File: Trap.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
@Override public void restoreFromBundle( Bundle bundle ) { pos = bundle.getInt( POS ); visible = bundle.getBoolean( VISIBLE ); if (bundle.contains(ACTIVE)){ active = bundle.getBoolean(ACTIVE); } }
Example 12
Source File: Ring.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
@Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); levelsToID = bundle.getFloat( LEVELS_TO_ID ); //pre-0.7.2 saves if (bundle.contains( "unfamiliarity" )){ levelsToID = bundle.getInt( "unfamiliarity" ) / 200f; } }
Example 13
Source File: Mob.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
@Override public void restoreFromBundle(Bundle bundle) { super.restoreFromBundle(bundle); String state = bundle.getString(STATE); setState(state); fraction = Fraction.values()[bundle.optInt(FRACTION, Fraction.DUNGEON.ordinal())]; if (bundle.contains(LOOT)) { loot = bundle.get(LOOT); lootChance = 1; } }
Example 14
Source File: SandalsOfNature.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle(bundle); name = bundle.getString( NAME ); if (bundle.contains(SEEDS)) Collections.addAll(seeds , bundle.getStringArray(SEEDS)); }
Example 15
Source File: Blandfruit.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override public void restoreFromBundle(Bundle bundle){ super.restoreFromBundle(bundle); if (bundle.contains( POTIONATTRIB )) { imbuePotion( (Potion)bundle.get( POTIONATTRIB ) ); //TODO: legacy code for pre-v0.2.3, remove when saves from that version are no longer supported. } else if (bundle.contains("name")) { name = bundle.getString("name"); if (name.equals("Healthfruit")) cook(new Sungrass.Seed()); else if (name.equals("Powerfruit")) cook(new Wandmaker.Rotberry.Seed()); else if (name.equals("Paralyzefruit")) cook(new Earthroot.Seed()); else if (name.equals("Invisifruit")) cook(new Blindweed.Seed()); else if (name.equals("Flamefruit")) cook(new Firebloom.Seed()); else if (name.equals("Frostfruit")) cook(new Icecap.Seed()); else if (name.equals("Visionfruit")) cook(new Fadeleaf.Seed()); else if (name.equals("Toxicfruit")) cook(new Sorrowmoss.Seed()); else if (name.equals("Floatfruit")) cook(new Stormvine.Seed()); else if (name.equals("Purefruit")) cook(new Dreamfoil.Seed()); } }
Example 16
Source File: Dungeon.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
public static void restore( Bundle bundle ){ for (LimitedDrops lim : values()){ if (bundle.contains(lim.name())){ lim.count = bundle.getInt(lim.name()); } else { lim.count = 0; } } }
Example 17
Source File: SecretRoom.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
public static void restoreRoomsFromBundle( Bundle bundle ) { runSecrets.clear(); if (bundle.contains( ROOMS )) { for (Class<? extends SecretRoom> type : bundle.getClassArray(ROOMS)) { if (type != null) runSecrets.add(type); } regionSecretsThisRun = bundle.getIntArray(REGIONS); } else { initForRun(); ShatteredPixelDungeon.reportException(new Exception("secrets array didn't exist!")); } }
Example 18
Source File: Ring.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); levelsToID = bundle.getFloat( LEVELS_TO_ID ); //pre-0.7.2 saves if (bundle.contains( "unfamiliarity" )){ levelsToID = bundle.getInt( "unfamiliarity" ) / 200f; } }
Example 19
Source File: ItemStatusHandler.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 4 votes |
private void restore( Bundle bundle, String[] allLabels, Integer[] allImages ) { ArrayList<String> labelsLeft = new ArrayList<>( Arrays.asList( allLabels ) ); ArrayList<Integer> imagesLeft = new ArrayList<>( Arrays.asList( allImages ) ); for (int i=0; i < items.length; i++) { Class<? extends T> item = items[i]; String itemName = item.toString(); if (bundle.contains( itemName + PFX_LABEL ) && Dungeon.version > 4) { String label = bundle.getString( itemName + PFX_LABEL ); labels.put( item, label ); labelsLeft.remove( label ); Integer image = bundle.getInt( itemName + PFX_IMAGE ); images.put( item, image ); imagesLeft.remove( image ); if (bundle.getBoolean( itemName + PFX_KNOWN )) { known.add( item ); } //if there's a new item, give it a random image //or.. if we're loading from an untrusted version, randomize the image to be safe. } else { int index = Random.Int( labelsLeft.size() ); labels.put( item, labelsLeft.get( index ) ); labelsLeft.remove( index ); images.put( item, imagesLeft.get( index ) ); imagesLeft.remove( index ); if (bundle.contains( itemName + PFX_KNOWN ) && bundle.getBoolean( itemName + PFX_KNOWN )) { known.add( item ); } } } }
Example 20
Source File: DriedRose.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 4 votes |
@Override public void restoreFromBundle(Bundle bundle) { super.restoreFromBundle(bundle); if (bundle.contains(DEFEND_POS)) defendingPos = bundle.getInt(DEFEND_POS); movingToDefendPos = bundle.getBoolean(MOVING_TO_DEFEND); }