Java Code Examples for com.watabou.utils.Bundle#getString()

The following examples show how to use com.watabou.utils.Bundle#getString() . 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: Rankings.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void restoreFromBundle( Bundle bundle ) {
	
	version	= bundle.getString( VERSION );
	info	= bundle.getString( REASON );
	win		= bundle.getBoolean( WIN );
	score	= bundle.getInt( SCORE );
          level	= bundle.getInt( LEVEL );
          depth	= bundle.getInt( DEPTH );
          diff = bundle.getInt( DIFF );

	heroClass	= HeroClass.restoreInBundle( bundle );
	armorTier	= bundle.getInt( TIER );
	
	gameFile	= bundle.getString( GAME );
}
 
Example 2
Source File: Rankings.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 6 votes vote down vote up
@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: Mob.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void restoreFromBundle( Bundle bundle ) {
	
	super.restoreFromBundle( bundle );

	String state = bundle.getString( STATE );
	if (state.equals( Sleeping.TAG )) {
		this.state = SLEEPING;
	} else if (state.equals( Wandering.TAG )) {
		this.state = WANDERING;
	} else if (state.equals( Hunting.TAG )) {
		this.state = HUNTING;
	} else if (state.equals( Fleeing.TAG )) {
		this.state = FLEEING;
	} else if (state.equals( Passive.TAG )) {
		this.state = PASSIVE;
	}

	enemySeen = bundle.getBoolean( SEEN );

	target = bundle.getInt( TARGET );
}
 
Example 4
Source File: Rankings.java    From shattered-pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
@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 5
Source File: Mob.java    From shattered-pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void restoreFromBundle( Bundle bundle ) {
	
	super.restoreFromBundle( bundle );

	String state = bundle.getString( STATE );
	if (state.equals( Sleeping.TAG )) {
		this.state = SLEEPING;
	} else if (state.equals( Wandering.TAG )) {
		this.state = WANDERING;
	} else if (state.equals( Hunting.TAG )) {
		this.state = HUNTING;
	} else if (state.equals( Fleeing.TAG )) {
		this.state = FLEEING;
	} else if (state.equals( Passive.TAG )) {
		this.state = PASSIVE;
	}

	enemySeen = bundle.getBoolean( SEEN );

	target = bundle.getInt( TARGET );

	if (bundle.contains(MAX_LVL)) maxLvl = bundle.getInt(MAX_LVL);
}
 
Example 6
Source File: Mob.java    From pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void restoreFromBundle( Bundle bundle ) {
	
	super.restoreFromBundle( bundle );
	
	String state = bundle.getString( STATE );
	if (state.equals( Sleeping.TAG )) {
		this.state = SLEEPEING;
	} else if (state.equals( Wandering.TAG )) {
		this.state = WANDERING;
	} else if (state.equals( Hunting.TAG )) {
		this.state = HUNTING;
	} else if (state.equals( Fleeing.TAG )) {
		this.state = FLEEING;
	} else if (state.equals( Passive.TAG )) {
		this.state = PASSIVE;
	}

	target = bundle.getInt( TARGET );
}
 
Example 7
Source File: Mob.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void restoreFromBundle( Bundle bundle ) {
	
	super.restoreFromBundle(bundle);

	String state = bundle.getString( STATE );

	if (state.equals( Sleeping.TAG )) {
		this.state = SLEEPING;
	} else if (state.equals( Wandering.TAG )) {
		this.state = WANDERING;
	} else if (state.equals( Hunting.TAG )) {
		this.state = HUNTING;
	} else if (state.equals( Fleeing.TAG )) {
		this.state = FLEEING;
	} else if (state.equals( Passive.TAG )) {
		this.state = PASSIVE;
	}

	enemySeen = bundle.getBoolean( SEEN );

	target = bundle.getInt( TARGET );
}
 
Example 8
Source File: Mob.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void restoreFromBundle( Bundle bundle ) {
	
	super.restoreFromBundle(bundle);
	
	String state = bundle.getString( STATE );
	if (state.equals( Sleeping.TAG )) {
		this.state = SLEEPING;
	} else if (state.equals( Wandering.TAG )) {
		this.state = WANDERING;
	} else if (state.equals( Hunting.TAG )) {
		this.state = HUNTING;
	} else if (state.equals( Fleeing.TAG )) {
		this.state = FLEEING;
	} else if (state.equals( Passive.TAG )) {
		this.state = PASSIVE;
	}

	target = bundle.getInt( TARGET );
       noticed = bundle.getBoolean( NOTICED );
       enemySeen = bundle.getBoolean( ALERTED );
}
 
Example 9
Source File: SandalsOfNature.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void restoreFromBundle( Bundle bundle ) {
	super.restoreFromBundle(bundle);
	name = bundle.getString( NAME );
	if (bundle.contains(SEEDS))
		Collections.addAll(seeds , bundle.getStringArray(SEEDS));
}
 
Example 10
Source File: Rankings.java    From pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void restoreFromBundle( Bundle bundle ) {
	
	info	= bundle.getString( REASON );
	win		= bundle.getBoolean( WIN );
	score	= bundle.getInt( SCORE );
	
	heroClass	= HeroClass.restoreInBundle( bundle );
	armorTier	= bundle.getInt( TIER );
	
	gameFile	= bundle.getString( GAME );
}
 
Example 11
Source File: Blandfruit.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@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 12
Source File: Mob.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@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 13
Source File: Rankings.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void restoreFromBundle( Bundle bundle ) {
	
	info	= bundle.getString  ( REASON );
	win		= bundle.getBoolean ( WIN    );
	score	= bundle.getInt     ( SCORE  );
	
	heroClass	= HeroClass.restoreFromBundle(bundle);

	gameFile	= bundle.getString( GAME );
	mod			= bundle.optString(MOD, ModdingMode.REMIXED);
}
 
Example 14
Source File: ItemStatusHandler.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
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 15
Source File: Dungeon.java    From pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
public static void loadGame( String fileName, boolean fullLoad ) throws IOException {
	
	Bundle bundle = gameBundle( fileName );
	
	Dungeon.challenges = bundle.getInt( CHALLENGES );
	
	Dungeon.level = null;
	Dungeon.depth = -1;
	
	if (fullLoad) {
		PathFinder.setMapSize( Level.WIDTH, Level.HEIGHT );
	}
	
	Scroll.restore( bundle );
	Potion.restore( bundle );
	Wand.restore( bundle );
	Ring.restore( bundle );
	
	potionOfStrength = bundle.getInt( POS );
	scrollsOfUpgrade = bundle.getInt( SOU );
	scrollsOfEnchantment = bundle.getInt( SOE );
	dewVial = bundle.getBoolean( DV );
	
	if (fullLoad) {
		chapters = new HashSet<Integer>();
		int ids[] = bundle.getIntArray( CHAPTERS );
		if (ids != null) {
			for (int id : ids) {
				chapters.add( id );
			}
		}
		
		Bundle quests = bundle.getBundle( QUESTS );
		if (!quests.isNull()) {
			Ghost.Quest.restoreFromBundle( quests );
			Wandmaker.Quest.restoreFromBundle( quests );
			Blacksmith.Quest.restoreFromBundle( quests );
			Imp.Quest.restoreFromBundle( quests );
		} else {
			Ghost.Quest.reset();
			Wandmaker.Quest.reset();
			Blacksmith.Quest.reset();
			Imp.Quest.reset();
		}
		
		Room.restoreRoomsFromBundle( bundle );
	}
	
	Bundle badges = bundle.getBundle( BADGES );
	if (!badges.isNull()) {
		Badges.loadLocal( badges );
	} else {
		Badges.reset();
	}
	
	QuickSlot.restore( bundle );
	
	@SuppressWarnings("unused")
	String version = bundle.getString( VERSION );
	
	hero = null;
	hero = (Hero)bundle.get( HERO );
	
	QuickSlot.compress();
	
	gold = bundle.getInt( GOLD );
	depth = bundle.getInt( DEPTH );
	
	Statistics.restoreFromBundle( bundle );
	Journal.restoreFromBundle( bundle );
	
	droppedItems = new SparseArray<ArrayList<Item>>();
	for (int i=2; i <= Statistics.deepestFloor + 1; i++) {
		ArrayList<Item> dropped = new ArrayList<Item>();
		for (Bundlable b : bundle.getCollection( String.format( DROPPED, i ) ) ) {
			dropped.add( (Item)b );
		}
		if (!dropped.isEmpty()) {
			droppedItems.put( i, dropped );
		}
	}
}
 
Example 16
Source File: DocumentPage.java    From shattered-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void restoreFromBundle(Bundle bundle) {
	super.restoreFromBundle(bundle);
	page = bundle.getString( PAGE );
}
 
Example 17
Source File: DocumentPage.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void restoreFromBundle(Bundle bundle) {
	super.restoreFromBundle(bundle);
	page = bundle.getString( PAGE );
}
 
Example 18
Source File: Dungeon.java    From remixed-dungeon with GNU General Public License v3.0 4 votes vote down vote up
private static void loadGameFromBundle(Bundle bundle, boolean fullLoad) {

        if(!bundle.optString("mod","Remixed").equals(ModdingMode.activeMod())) {
            EventCollector.logException(new Exception("loading save from another mod"));
        }

        Dungeon.gameId = bundle.optString(GAME_ID, Utils.UNKNOWN);
        EntityIdSource.setLastUsedId(bundle.optInt(LAST_USED_ID,1));

        Treasury.reset();

        Scroll.restore(bundle);
        Potion.restore(bundle);
        Wand.restore(bundle);
        Ring.restore(bundle);
        QuickSlot.restore(bundle);

        potionOfStrength = bundle.getInt(POS);
        scrollsOfUpgrade = bundle.getInt(SOU);
        arcaneStyli = bundle.getInt(AS);
        dewVial = bundle.getBoolean(DV);
        transmutation = bundle.getInt(WT);

        realtime = bundle.getBoolean(REALTIME);
        setChallenges(bundle.optInt(CHALLENGES,0));

        if (fullLoad) {
            chapters = new HashSet<>();
            int[] ids = bundle.getIntArray(CHAPTERS);
            for (int id : ids) {
                chapters.add(id);
            }

            Bundle quests = bundle.getBundle(QUESTS);
            if (!quests.isNull()) {
                Ghost.Quest.restoreFromBundle(quests);
                WandMaker.Quest.restoreFromBundle(quests);
                Blacksmith.Quest.restoreFromBundle(quests);
                Imp.Quest.restoreFromBundle(quests);
                AzuterronNPC.Quest.restoreFromBundle(quests);
                ScarecrowNPC.Quest.restoreFromBundle(quests);
                CagedKobold.Quest.restoreFromBundle(quests);
                PlagueDoctorNPC.Quest.restoreFromBundle(quests);
            } else {
                Ghost.Quest.reset();
                WandMaker.Quest.reset();
                Blacksmith.Quest.reset();
                Imp.Quest.reset();
                AzuterronNPC.Quest.reset();
                ScarecrowNPC.Quest.reset();
                CagedKobold.Quest.reset();
                PlagueDoctorNPC.Quest.reset();
            }

            Room.restoreRoomsFromBundle(bundle);
        }

        Bundle badges = bundle.getBundle(BADGES);
        if (!badges.isNull()) {
            Badges.loadLocal(badges);
        } else {
            Badges.reset();
        }

        @SuppressWarnings("unused")
        String version = bundle.getString(VERSION);

        hero = (Hero) bundle.get(HERO);
        if(hero==null) {
            throw new TrackedRuntimeException("no hero in bundle");
        }

        depth = bundle.getInt(DEPTH);

        Statistics.restoreFromBundle(bundle);
        Journal.restoreFromBundle(bundle);
        Logbook.restoreFromBundle(bundle);
        LuaEngine.getEngine().require(LuaEngine.SCRIPTS_LIB_STORAGE).get("deserializeGameData").call(bundle.getString(SCRIPTS_DATA));

        moveTimeoutIndex = RemixedDungeon.limitTimeoutIndex(bundle.optInt(MOVE_TIMEOUT, Integer.MAX_VALUE));
    }
 
Example 19
Source File: ItemStatusHandler.java    From pixel-dungeon with GNU General Public License v3.0 3 votes vote down vote up
private void restore( Bundle bundle, String[] allLabels, Integer[] allImages ) {
	
	ArrayList<String> labelsLeft = new ArrayList<String>( Arrays.asList( allLabels ) );
	ArrayList<Integer> imagesLeft = new ArrayList<Integer>( Arrays.asList( allImages ) );
	
	for (int i=0; i < items.length; i++) {
		
		Class<? extends T> item = (Class<? extends T>)(items[i]);
		String itemName = item.toString();
		
		if (bundle.contains( itemName + PFX_LABEL )) {
			
			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 );
			}
			
		} 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 );
			
		}
	}
}
 
Example 20
Source File: ItemStatusHandler.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 3 votes vote down vote up
private void restore( Bundle bundle, String[] allLabels, Integer[] allImages ) {
	
	ArrayList<String> labelsLeft = new ArrayList<String>( Arrays.asList( allLabels ) );
	ArrayList<Integer> imagesLeft = new ArrayList<Integer>( Arrays.asList( allImages ) );
	
	for (int i=0; i < items.length; i++) {
		
		Class<? extends T> item = (Class<? extends T>)(items[i]);
		String itemName = item.toString();
		
		if (bundle.contains( itemName + PFX_LABEL )) {
			
			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 );
			}
			
		} 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 );
			
		}
	}
}