예제 #1
0
/* Acquirement for PRIME. */
shExecResult
doMatterCompiler (shObject *computer, shObject *disk)
{
    if (disk->isBuggy ()) {
        I->p ("Your computer transforms into dust.");
        if (Hero.mProfession == SoftwareEngineer) {
            I->p ("You've heard buggy disks of matter compiler behave like this.");
            disk->setKnown ();
        } else {
            disk->maybeName ();
        }
        return kDestroyComputer;
    }
    int weight = 0;
    int true_orgasmatron = 0;
    if (!disk->isKnown ()) {
        I->p ("You have found a floppy disk of matter compiler!");
        disk->setKnown ();
    }
    /* Proceed to decompile stuff. */
    if (Hero.is (kConfused)) { /* Additionally targets your equipment. */
        shObjectVector v;
        selectObjectsByFunction (&v, Hero.mInventory, &shObject::isWorn);
        int count = 0;
        for (int i = 0; i < v.count (); ++i) {
            shObject *obj = v.get (i);
            if (obj->isA (kImplant) and
                obj->mIlkId != kObjTorc and obj->mIlkId != kObjMechaDendrites)
                continue; /* Implants residing in brain are safe. */
            ++count;
            weight += obj->myIlk ()->mWeight;
            Hero.useUpOneObjectFromInventory (obj);
        }
        if (count) {
            I->p ("Your armor is decompiled.");
        }
        if (Hero.mWeapon) {
            if (Hero.mWeapon == computer) {
                I->p ("Your computer transforms into dust.");
                return kDestroyComputer;
            }
            if (Hero.mWeapon->isA (kObjTheOrgasmatron)) {
                true_orgasmatron = 1;
            }
            I->p ("%s %s decompiled.", YOUR (Hero.mWeapon),
                Hero.mWeapon->mCount > 1 ? "are" : "is");
            weight += Hero.mWeapon->myIlk ()->mWeight * Hero.mWeapon->mCount;
            Hero.useUpSomeObjectsFromInventory (Hero.mWeapon, Hero.mWeapon->mCount);
        }
    } /* Decompile web hero might be entangled in. */
    if (Hero.mTrapped.mWebbed) {
        I->p ("The web holding you is decompiled!");
        weight += 50 * Hero.mTrapped.mWebbed;
        Hero.mTrapped.mWebbed = 0;
    } /* Decompile duct tape hero might be held by. */
    if (Hero.mTrapped.mWebbed) {
        I->p ("The duct tape holding you is decompiled!");
        weight += 5 * Hero.mTrapped.mTaped;
        Hero.mTrapped.mTaped = 0;
    } /* Decompile sewage. */
    if (Level->mSquares[Hero.mX][Hero.mY].mTerr == kSewage) {
        I->p ("The sewage around you is decompiled!");
        Level->mSquares[Hero.mX][Hero.mY].mTerr = kSewerFloor;
        /* Hero might be drowning, but this is handled by decompileFeature () */
        weight += 250;
    } /* Decompile objects too. */
    shObjectVector *v = Level->getObjects (Hero.mX, Hero.mY);
    if (v) { /* Nuke whole stack of items. */
        if (v->count () > 1) {
            I->p ("Items on ground are decompiled.");
        } else {
            I->p ("Something on ground is decompiled.");
        }
        for (int i = 0; i < v->count (); ++i) {
            shObject *obj = v->get (i);
            weight += obj->myIlk ()->mWeight;
            if (obj->isA (kObjTheOrgasmatron)) {
                true_orgasmatron = 1;
            }
            if (obj->isUnpaid ()) {
                Hero.usedUpItem (obj, obj->mCount, "decompile");
            }
            delete obj;
        }
        delete v;
        Level->setObjects (Hero.mX, Hero.mY, NULL);
    } /* Perhaps decompile some terrain feature? */
    if (Level->getFeature (Hero.mX, Hero.mY)) {
        weight += decompileFeature ();
        if (Hero.mState == kDead)  return kNoExpiry;
    } /* Unavoidable weight loss. Some particles escape. */
    if        (disk->isInfected ()) {
        weight = weight * 75 / 100;
    } else if (disk->isDebugged ()) {
        weight = weight * 90 / 100;
    } else if (disk->isOptimized ()) {
        weight = weight * 95 / 100;
    } /* (De)compilation should not be attempted in irradiated level/room. */
    if (Level->isRadioactive (Hero.mX, Hero.mY)) {
        weight /= 2;
        I->p ("Particles behave in unstable way.  Half of them speed away.");
        I->pause ();
    }
    int objs_created = 0;
    int feature_created = 0;
    int last_ok = 1;
    if (weight) { /* Create stuff! */
        int numitems = RNG (1, 3 + disk->mBugginess);
        while (numitems-- and weight and last_ok) {
            const char *ilkstr = NULL;
            shFeature::Type kind = NOFEATURE;
            if (true_orgasmatron) { /* Give it back. */
                shObject *orgasmatron = createObject ("Bizarro Orgasmatron", 0);
                Level->putObject (orgasmatron, Hero.mX, Hero.mY);
                true_orgasmatron = 0;
                continue;
            }
            if (hackingRoll (computer) >= 20) {
                ilkstr = pickCompilerTarget (hackingRoll (computer), &kind);
            } else {
                if (weight >= 50000 and !RNG (20)) {
                    switch (RNG (2)) {
                        case 0: kind = shFeature::kRadTrap; break;
                        case 1: kind = shFeature::kVat; break;
                    }
                }
            }
            if (kind == NOFEATURE) { /* Generate an object. */
                last_ok = compileObject (ilkstr, hackingRoll (computer), &weight);
                if (!last_ok) break; /* Out of particles or an error. */
                objs_created += last_ok;
            } else {
                last_ok = compileFeature (kind, hackingRoll (computer), &weight);
                feature_created = last_ok;
            }
        }
    } /* Report results. */
    if (feature_created) {
        shFeature *f = Level->getFeature (Hero.mX, Hero.mY);
        f->mTrapUnknown = 0;
        I->p ("%s forms.", f->getShortDescription ());
    }
    if (objs_created > 1) {
        I->p ("Some items form at your feet.");
    } else if (objs_created == 1) {
        I->p ("An item forms at your feet.");
    }
    if (!objs_created and !feature_created) {
        I->p ("Matter compilation failed entirely.");
    } /* If a lot of weight is left do not eat it all. */
    shObjectIlk *junk = &AllIlks[kObjJunk];
    shFeature *f = Level->getFeature (Hero.mX, Hero.mY);
    if (f) { /* What cannot be transformed into junk may fill pit/hole. */
        int unglued = weight % junk->mWeight;
        switch (f->mType) {
            case shFeature::kHole:
                if (unglued >= 20000) {
                    weight -= 20000;
                    I->p ("The hole below you is sealed.");
                    Level->removeFeature (f);
                } else if (unglued >= 10000) {
                    I->p ("The hole below you is partially filled.");
                    f->mType = shFeature::kPit;
                }
                break;
            case shFeature::kPit:
                if (unglued >= 10000) {
                    weight -= 10000;
                    Level->removeFeature (f);
                    if (Hero.mZ == -1) {
                        I->p ("You are lifted as the pit you were in is sealed with matter.");
                        Hero.mZ = 0;
                        Hero.mTrapped.mInPit = 0;
                        Hero.mTrapped.mDrowning = 0;
                    } else {
                        I->p ("The pit below you is filled.");
                    }
                }
                break;
            default:
                break;
        }
    }
    if (weight > junk->mWeight) {
        I->p ("Excess matter is haphazardly glued into piles of junk.");
        for (int i = 0; i < weight / junk->mWeight; ++i) {
            shObject *obj = createObject ("heap of space junk", 0);
            Level->putObject (obj, Hero.mX, Hero.mY);
        }
    } else if (weight > 0) {
        I->p ("Leftover particles disperse.");
    }
    return kNormal;
}
예제 #2
0
bool XSAppBuilder::packProject()
{
    if(projectPath.isEmpty())
    {
        return false;
    }

    bool ret = false;
    QDir dir(projectPath);
    QFileInfoList infoList = dir.entryInfoList();

    for(int i = 0; i < infoList.size(); i++)
    {
        if(infoList.at(i).isDir())
        {
            QDir jsDir = QDir(infoList.at(i).absoluteFilePath());
            QFileInfoList jsInforList = jsDir.entryInfoList();

            if(jsDir.dirName() == "scripts")
            {
                for(int j = 0; j < jsInforList.size(); j++)
                {
                    if(jsInforList.at(j).suffix() == "js")
                    {
                        QString prefix = jsDir.dirName() + "_";
                        ret = compileScript(jsInforList.at(j), prefix);
                        break;
                    }
                }
            }

            continue;
        }

        if(infoList.at(i).suffix() == "xpk")
        {
            continue;
        }
        else if(infoList.at(i).suffix() == "xml" || infoList.at(i).suffix() == "json")
        {
            ret = compileObject(infoList.at(i));
        }
        else if(infoList.at(i).suffix() == "js")
        {
            ret = compileScript(infoList.at(i), "");
        }
        else
        {
            ret = compileBinary(infoList.at(i));
        }

        if(ret == false)
        {
            return ret;
        }
    }

    ret = writeObject();

    return ret;
}