Search in sources :

Example 1 with GameScreen

use of ultima.GameScreen in project ultimate-java by pantinor.

the class HorseService method nextDialog.

@Override
public boolean nextDialog() {
    switch(state) {
        case WAIT_BUY_INPUT:
            displayToScreen(String.format(welcomeMessage, vendor.getName(), vendor.getOwner()));
            displayToScreen("Can I interest thee in horses?");
            break;
        case WAIT_BUY_ONE:
            displayToScreen("For only 200g.p thou can have the best. Wilt thou buy?");
            break;
        case BUY_ITEM:
            party.adjustGold(-currentSelectedItem.getPrice());
            displayToScreen("Here, a better breed thou shalt not find ever!");
            if (screen != null) {
                Creature cr = Ultima4.creatures.getInstance(CreatureType.horse, Ultima4.standardAtlas);
                Vector3 v = screen.getCurrentMapCoords();
                cr.currentX = (int) v.x;
                cr.currentY = (int) v.y;
                party.getContext().getCurrentMap().addCreature(cr);
                ((GameScreen) screen).board((int) v.x, (int) v.y);
            }
            return false;
        case DECLINE_BUY:
            displayToScreen("A shame, thou looks like thou could use a good horse!");
            return false;
        case FAREWELL:
            displayToScreen("Fare thee well!");
            return false;
        default:
            displayToScreen("I cannot help thee with that.");
            state = ConvState.WAIT_BUY_INPUT;
            break;
    }
    return true;
}
Also used : GameScreen(ultima.GameScreen) Creature(objects.Creature) Vector3(com.badlogic.gdx.math.Vector3)

Example 2 with GameScreen

use of ultima.GameScreen in project ultimate-java by pantinor.

the class BaseMap method searchLocation.

public ItemMapLabels searchLocation(BaseScreen screen, Party p, int x, int y, int z) {
    SaveGame sg = p.getSaveGame();
    if (labels == null) {
        return null;
    }
    Label tmp = null;
    for (Label l : labels) {
        if (l.getX() == x && l.getY() == y && l.getZ() == z) {
            tmp = l;
        }
    }
    if (tmp == null) {
        return null;
    }
    int expPoints = 0;
    ItemMapLabels label = ItemMapLabels.valueOf(ItemMapLabels.class, tmp.getName());
    boolean added = false;
    int conditions = label.getConditions();
    if ((conditions & SC_NEWMOONS) > 0 && !(GameScreen.trammelphase == 0 && GameScreen.feluccaphase == 0)) {
        return null;
    }
    if ((conditions & SC_FULLAVATAR) > 0) {
        for (int i = 0; i < 8; i++) {
            if (sg.karma[i] != 0) {
                return null;
            }
        }
    }
    if ((conditions & SC_REAGENTDELAY) > 0 && (sg.moves & 0xF0) == sg.lastreagent) {
        return null;
    }
    switch(label) {
        case bell:
            if ((sg.items & Item.BELL.getLoc()) > 0) {
                break;
            }
            sg.items |= Item.BELL.getLoc();
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            expPoints = 400;
            added = true;
            break;
        case blackstone:
            if ((sg.stones & Stone.BLACK.getLoc()) > 0) {
                break;
            }
            sg.stones |= Stone.BLACK.getLoc();
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            expPoints = 200;
            added = true;
            break;
        case bluestone:
            if ((sg.stones & Stone.BLUE.getLoc()) > 0) {
                break;
            }
            sg.stones |= Stone.BLUE.getLoc();
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            expPoints = 200;
            added = true;
            break;
        case book:
            if ((sg.items & Item.BOOK.getLoc()) > 0) {
                break;
            }
            sg.items |= Item.BOOK.getLoc();
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            expPoints = 400;
            added = true;
            break;
        case candle:
            if ((sg.items & Item.CANDLE.getLoc()) > 0) {
                break;
            }
            sg.items |= Item.CANDLE.getLoc();
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            expPoints = 400;
            added = true;
            break;
        case compassionrune:
            if ((sg.runes & Virtue.COMPASSION.getLoc()) > 0) {
                break;
            }
            sg.runes |= Virtue.COMPASSION.getLoc();
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            expPoints = 100;
            added = true;
            break;
        case greenstone:
            if ((sg.stones & Stone.GREEN.getLoc()) > 0) {
                break;
            }
            sg.stones |= Stone.GREEN.getLoc();
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            expPoints = 200;
            added = true;
            break;
        case honestyrune:
            if ((sg.runes & Virtue.HONESTY.getLoc()) > 0) {
                break;
            }
            sg.runes |= Virtue.HONESTY.getLoc();
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            expPoints = 100;
            added = true;
            break;
        case honorrune:
            if ((sg.runes & Virtue.HONOR.getLoc()) > 0) {
                break;
            }
            sg.runes |= Virtue.HONOR.getLoc();
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            expPoints = 100;
            added = true;
            break;
        case horn:
            if ((sg.items & Item.HORN.getLoc()) > 0) {
                break;
            }
            sg.items |= Item.HORN.getLoc();
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            expPoints = 400;
            added = true;
            break;
        case humilityrune:
            if ((sg.runes & Virtue.HUMILITY.getLoc()) > 0) {
                break;
            }
            sg.runes |= Virtue.HUMILITY.getLoc();
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            expPoints = 100;
            added = true;
            break;
        case justicerune:
            if ((sg.runes & Virtue.JUSTICE.getLoc()) > 0) {
                break;
            }
            sg.runes |= Virtue.JUSTICE.getLoc();
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            expPoints = 100;
            added = true;
            break;
        case orangestone:
            if ((sg.stones & Stone.ORANGE.getLoc()) > 0) {
                break;
            }
            sg.stones |= Stone.ORANGE.getLoc();
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            expPoints = 200;
            added = true;
            break;
        case purplestone:
            if ((sg.stones & Stone.PURPLE.getLoc()) > 0) {
                break;
            }
            sg.stones |= Stone.PURPLE.getLoc();
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            expPoints = 200;
            added = true;
            break;
        case redstone:
            if ((sg.stones & Stone.RED.getLoc()) > 0) {
                break;
            }
            sg.stones |= Stone.RED.getLoc();
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            expPoints = 200;
            added = true;
            break;
        case sacrificerune:
            if ((sg.runes & Virtue.SACRIFICE.getLoc()) > 0) {
                break;
            }
            sg.runes |= Virtue.SACRIFICE.getLoc();
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            expPoints = 100;
            added = true;
            break;
        case skull:
            if ((sg.items & Item.SKULL.getLoc()) > 0) {
                break;
            }
            sg.items |= Item.SKULL.getLoc();
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            expPoints = 400;
            added = true;
            break;
        case spiritualityrune:
            if ((sg.runes & Virtue.SPIRITUALITY.getLoc()) > 0) {
                break;
            }
            sg.runes |= Virtue.SPIRITUALITY.getLoc();
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            expPoints = 100;
            added = true;
            break;
        case valorrune:
            if ((sg.runes & Virtue.VALOR.getLoc()) > 0) {
                break;
            }
            sg.runes |= Virtue.VALOR.getLoc();
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            expPoints = 100;
            added = true;
            break;
        case wheel:
            if ((sg.items & Item.WHEEL.getLoc()) > 0) {
                break;
            }
            sg.items |= Item.WHEEL.getLoc();
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            expPoints = 400;
            added = true;
            break;
        case whitestone:
            if ((sg.stones & Stone.WHITE.getLoc()) > 0) {
                break;
            }
            sg.stones |= Stone.WHITE.getLoc();
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            expPoints = 200;
            added = true;
            break;
        case yellowstone:
            if ((sg.stones & Stone.YELLOW.getLoc()) > 0) {
                break;
            }
            sg.stones |= Stone.YELLOW.getLoc();
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            expPoints = 200;
            added = true;
            break;
        case mysticarmor:
            if (sg.armor[ArmorType.MYSTICROBE.ordinal()] > 0) {
                break;
            }
            // all party members would have it
            sg.armor[ArmorType.MYSTICROBE.ordinal()] += 8;
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            expPoints = 400;
            sg.lastreagent = sg.moves & 0xF0;
            added = true;
            break;
        case mysticswords:
            if (sg.weapons[WeaponType.MYSTICSWORD.ordinal()] > 0) {
                break;
            }
            sg.weapons[WeaponType.MYSTICSWORD.ordinal()] += 8;
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            expPoints = 400;
            sg.lastreagent = sg.moves & 0xF0;
            added = true;
            break;
        case mandrake1:
        case mandrake2:
            sg.reagents[Reagent.MANDRAKE.ordinal()] += new XORShiftRandom().nextInt(8) + 2;
            if (sg.reagents[Reagent.MANDRAKE.ordinal()] > 99) {
                sg.reagents[Reagent.MANDRAKE.ordinal()] = 99;
            }
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            sg.lastreagent = sg.moves & 0xF0;
            added = true;
            break;
        case nightshade1:
        case nightshade2:
            sg.reagents[Reagent.NIGHTSHADE.ordinal()] += new XORShiftRandom().nextInt(8) + 2;
            if (sg.reagents[Reagent.NIGHTSHADE.ordinal()] > 99) {
                sg.reagents[Reagent.NIGHTSHADE.ordinal()] = 99;
            }
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            sg.lastreagent = sg.moves & 0xF0;
            added = true;
            break;
        case telescope:
            if (screen instanceof GameScreen) {
                GameScreen gameScreen = (GameScreen) screen;
                gameScreen.peerTelescope();
            }
            break;
        case balloon:
            break;
        case lockelake:
            break;
        case maskofminax:
            if ((sg.items & Item.MASK_MINAX.getLoc()) > 0) {
                break;
            }
            sg.items |= Item.MASK_MINAX.getLoc();
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            expPoints = 200;
            sg.lastreagent = sg.moves & 0xF0;
            added = true;
            break;
        case rageofgod:
            if ((sg.items & Item.RAGE_GOD.getLoc()) > 0) {
                break;
            }
            sg.items |= Item.RAGE_GOD.getLoc();
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            expPoints = 400;
            sg.lastreagent = sg.moves & 0xF0;
            added = true;
            break;
        case ironrunemold:
            if ((sg.items & Item.RUNE_MOLD.getLoc()) > 0) {
                break;
            }
            sg.items |= Item.RUNE_MOLD.getLoc();
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            expPoints = 200;
            sg.lastreagent = sg.moves & 0xF0;
            added = true;
            break;
        case blackironore:
            if ((sg.items & Item.IRON_ORE.getLoc()) > 0) {
                break;
            }
            sg.items |= Item.IRON_ORE.getLoc();
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            expPoints = 200;
            sg.lastreagent = sg.moves & 0xF0;
            added = true;
            break;
        case magicparchment:
            if ((sg.items & Item.PARCH.getLoc()) > 0) {
                break;
            }
            sg.items |= Item.PARCH.getLoc();
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            expPoints = 200;
            sg.lastreagent = sg.moves & 0xF0;
            added = true;
            break;
        case greedrune:
            if ((sg.items & Item.GREED_RUNE.getLoc()) > 0) {
                break;
            }
            sg.items |= Item.GREED_RUNE.getLoc();
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            expPoints = 200;
            sg.lastreagent = sg.moves & 0xF0;
            added = true;
            break;
        case songhumility:
            if ((sg.items & Item.SONG_HUM.getLoc()) > 0) {
                break;
            }
            sg.items |= Item.SONG_HUM.getLoc();
            p.adjustKarma(KarmaAction.FOUND_ITEM);
            expPoints = 400;
            sg.lastreagent = sg.moves & 0xF0;
            added = true;
            break;
        default:
            break;
    }
    if (expPoints > 0) {
        p.getMember(0).awardXP(expPoints);
    }
    if (added) {
        return label;
    }
    return null;
}
Also used : GameScreen(ultima.GameScreen) XORShiftRandom(util.XORShiftRandom)

Aggregations

GameScreen (ultima.GameScreen)2 Vector3 (com.badlogic.gdx.math.Vector3)1 Creature (objects.Creature)1 XORShiftRandom (util.XORShiftRandom)1