Exemplo n.º 1
0
Engine::Engine()
{
    Sanguosha = this;

    addPackage(NewMeleeCard());
    addPackage(NewExclusiveCard());
    addPackage(NewMeleeSS());
    addPackage(NewMeleeDS());
    addPackage(NewMeleeSF());

    //addScenario(NewGuanduScenario());
    //addScenario(NewFanchengScenario());
    //addScenario(NewCoupleScenario());
    //addScenario(NewHongyanScenario());
    //addScenario(NewZombieScenario());
    //addScenario(NewLegendScenario());
    //addScenario(NewImpasseScenario());

    // available game modes
    modes["02p"] = tr("2 players");
    //modes["02pbb"] = tr("2 players (using blance beam)");
    modes["02_1v1"] = tr("2 players (KOF style)");
    modes["03p"] = tr("3 players");
    modes["04p"] = tr("4 players");
    // modes["04_1v3"] = tr("4 players (Hulao Pass)");
    modes["05p"] = tr("5 players");
    modes["06p"] = tr("6 players");
    modes["06pd"] = tr("6 players (2 renegades)");
    modes["06_3v3"] = tr("6 players (3v3)");
    modes["07p"] = tr("7 players");
    modes["08p"] = tr("8 players");
    modes["08pd"] = tr("8 players (2 renegades)");
    // modes["08boss"] = tr("8 players (boss mode)");
    // modes["08same"] = tr("8 players (same mode)");
    modes["09p"] = tr("9 players");
    modes["10p"] = tr("10 players");

    //challenge_mode_set = NULL;
    challenge_mode_set = new ChallengeModeSet(this);
    //addPackage(challenge_mode_set);

    // translations.insert("bossmode", tr("Boss mode"));

    connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(deleteLater()));

    QString error_msg;
    lua = createLuaState(false, error_msg);
    if(lua == NULL){
        QMessageBox::warning(NULL, tr("Lua script error"), error_msg);
        exit(1);
    }
}
Exemplo n.º 2
0
Engine::Engine()
{
    Sanguosha = this;

    lua = CreateLuaState();
    DoLuaScript(lua, "lua/config.lua");

    QStringList package_names = GetConfigFromLuaState(lua, "package_names").toStringList();
    foreach(QString name, package_names)
        if(name != "ThreeKingdoms")
            addPackage(name);

    addPackage("ThreeKingdoms");

    QStringList scene_names = GetConfigFromLuaState(lua, "scene_names").toStringList();
    foreach(QString name, scene_names)
        addScenario(name);

    DoLuaScript(lua, "lua/sanguosha.lua");

    // available game modes
    modes["02p"] = tr("2 players");
    //modes["02pbb"] = tr("2 players (using blance beam)");
    modes["02_1v1"] = tr("2 players (KOF style)");
    modes["03p"] = tr("3 players");
    modes["03_3kingdoms"] = tr("3 players(3 kingdoms mode)");
    modes["04p"] = tr("4 players");
    modes["04_1v3"] = tr("4 players (Hulao Pass)");
    modes["05p"] = tr("5 players");
    modes["06p"] = tr("6 players");
    modes["06_3v3"] = tr("6 players (3v3)");
    modes["06pd"] = tr("6 players (2 renegades)");
    modes["07p"] = tr("7 players");
    modes["08p"] = tr("8 players");
    modes["08pd"] = tr("8 players (2 renegades)");
    modes["08pz"] = tr("8 players (0 renegade)");
    modes["09p"] = tr("9 players");
    modes["10pd"] = tr("10 players");
    modes["10p"] = tr("10 players (1 renegade)");
    modes["10pz"] = tr("10 players (0 renegade)");

    connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(deleteLater()));



    foreach(QString ban, getBanPackages()){
        addBanPackage(ban);
    }
Exemplo n.º 3
0
void Engine::addPackage(const QString &name) {
    Package *pack = PackageAdder::packages()[name];
    if (pack)
        addPackage(pack);
    else
        qWarning("Package %s cannot be loaded!", qPrintable(name));
}
Exemplo n.º 4
0
int rpmtsAddReinstallElement(rpmts ts, Header h, fnpyKey key)
{
    if (rpmtsSetupTransactionPlugins(ts) == RPMRC_FAIL)
	return 1;
    /* TODO: pull relocations from installed package */
    /* TODO: should reinstall of non-installed package fail? */
    return addPackage(ts, h, key, RPMTE_REINSTALL, NULL);
}
Exemplo n.º 5
0
int rpmtsAddInstallElement(rpmts ts, Header h,
			fnpyKey key, int upgrade, rpmRelocation * relocs)
{
    int op = (upgrade == 0) ? RPMTE_INSTALL : RPMTE_UPGRADE;
    if (rpmtsSetupTransactionPlugins(ts) == RPMRC_FAIL)
	return 1;
    return addPackage(ts, h, key, op, relocs);
}
Exemplo n.º 6
0
void Engine::addPackage(const QString &name){
    typedef Package * (*package_creator)();
    package_creator creator = GetSymbol<package_creator>(lib, name.toAscii());

    if(creator){
        addPackage(creator());
    }else
        qWarning("Package %s cannot be loaded!", qPrintable(name));
}
Exemplo n.º 7
0
void PkInstallProvideFiles::search()
{
    PkTransaction *transaction = new PkTransaction(this);
    transaction->setupTransaction(Daemon::searchFiles(m_args,
                                                      Transaction::FilterArch | Transaction::FilterNewest));
    setTransaction(Transaction::RoleSearchFile, transaction);
    connect(transaction, SIGNAL(finished(PkTransaction::ExitStatus)),
            this, SLOT(searchFinished(PkTransaction::ExitStatus)), Qt::UniqueConnection);
    connect(transaction, SIGNAL(package(PackageKit::Transaction::Info,QString,QString)),
            this, SLOT(addPackage(PackageKit::Transaction::Info,QString,QString)));
}
Exemplo n.º 8
0
Engine::Engine()
{
    Sanguosha = this;

    lua = CreateLuaState();
    DoLuaScript(lua, "lua/config.lua");

    QStringList package_names = GetConfigFromLuaState(lua, "package_names").toStringList();
    foreach(QString name, package_names)
        addPackage(name);

    QStringList scene_names = GetConfigFromLuaState(lua, "scene_names").toStringList();
    foreach(QString name, scene_names)
        addScenario(name);

    DoLuaScript(lua, "lua/sanguosha.lua");

    // available game modes
    modes["02p"] = tr("2 players");
    //modes["02pbb"] = tr("2 players (using blance beam)");
    modes["02_1v1"] = tr("2 players (KOF style)");
    modes["03p"] = tr("3 players");
    modes["04p"] = tr("4 players");
    modes["04_1v3"] = tr("4 players (Hulao Pass)");
    modes["05p"] = tr("5 players");
    modes["05_2v3"] = tr("5 players (Changban Slope)");
    modes["06p"] = tr("6 players");
    modes["06pd"] = tr("6 players (2 renegades)");
    modes["06_3v3"] = tr("6 players (3v3)");
    modes["07p"] = tr("7 players");
    modes["08p"] = tr("8 players");
    modes["08pd"] = tr("8 players (2 renegades)");
    modes["08pz"] = tr("8 players (0 renegade)");
    modes["09p"] = tr("9 players");
    modes["10pd"] = tr("10 players");
    modes["10p"] = tr("10 players (1 renegade)");
    modes["10pz"] = tr("10 players (0 renegade)");

    connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(deleteLater()));

    foreach(QString ban, getBanPackages())
        addBanPackage(ban);

    foreach(const Skill *skill, skills.values()){
        Skill *mutable_skill = const_cast<Skill *>(skill);
        mutable_skill->initMediaSource();
    }
}
Exemplo n.º 9
0
PackageModel::PackageModel( QObject* parent )
    : QAbstractItemModel( parent )
    , storage( 0 )
{
    networked = AbstractPackageController::factory( AbstractPackageController::network, this );
    installed = AbstractPackageController::factory( AbstractPackageController::installed, this );

    // can only have a max of 15 top level items
    rootItems << installed << networked;    //this must stay in sync with installedIndex
    //and networkedIndex

    for ( int i = 0; i < rootItems.count(); i++ )
        connect( rootItems[i], SIGNAL(updated()),
                 this, SLOT(controllerUpdate()) );
    connect( networked, SIGNAL(packageInstalled(InstallControl::PackageInfo)),
             installed, SLOT(addPackage(InstallControl::PackageInfo)) );
    connect( networked, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
             this, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)));
    connect( networked, SIGNAL(rowsRemoved(QModelIndex,int,int)),
             this, SIGNAL(rowsRemoved(QModelIndex,int,int)));
    connect( networked, SIGNAL(packageInstalled(InstallControl::PackageInfo)),
             this, SLOT(packageInstalled(InstallControl::PackageInfo)) );
    connect( networked, SIGNAL(serverStatus(QString)),
             this, SLOT(serverStatusUpdated(QString)) );

    // can only have a max of 4 columns, if more are needed, change the
    // macros used for PackageModel::index(...) below
    // columnHeads << "Name" << "Size";

    QStorageMetaInfo *s = QStorageMetaInfo::instance();
    connect( s, SIGNAL(disksChanged()),
             this, SLOT(publishTargets()) );
    connect( this, SIGNAL(targetsUpdated(QStringList)),
             installed, SLOT(reloadInstalledLocations(QStringList)) );

    if ( !QDir( Qtopia::packagePath() ).exists() )
        QDir::root().mkpath( Qtopia::packagePath() );
}
Exemplo n.º 10
0
void Engine::addScenario(Scenario *scenario) {
    QString key = scenario->objectName();
    m_scenarios[key] = scenario;
    addPackage(scenario);
}
Exemplo n.º 11
0
Engine::Engine()
{
    Sanguosha = this;

    QStringList package_names;
    package_names << "StandardCard"
                  << "StandardExCard"
                  << "Maneuvering"
                  << "SPCard"
                  << "YitianCard"
                  << "Nostalgia"
                  << "Joy"
                  << "Disaster"
                  << "JoyEquip"
                  << "DishaCard"
                  << "QHSEquip"
                  << "Hide"

                  << "Standard"
                  << "Wind"
                  << "Fire"
                  << "Thicket"
                  << "Mountain"
                  << "God"
                  << "SP"
                  << "YJCM"
                  << "YJCM2012"
                  << "Special3v3"
                  << "BGM"
                  << "Yitian"
                  << "Wisdom"
                  << "Huangjin"
                  << "Ghost"
                  << "QHS"
                  << "YJ1st"
                  << "TBdiy"
                  << "Yan"
                  << "ChangbanSlope"
                  << "Test" ;

    foreach(QString name, package_names)
        addPackage(name);

    QStringList scene_names;
    scene_names << "Guandu"
                << "Fancheng"
                << "Couple"
                << "Zombie"
                << "Impasse"
                << "Custom";

    for(int i=1; i<=21; i++){
        scene_names << QString("MiniScene_%1").arg(i, 2, 10, QChar('0'));
    }

    foreach(QString name, scene_names)
        addScenario(name);

    foreach(const Skill *skill, skills.values()){
        Skill *mutable_skill = const_cast<Skill *>(skill);
        mutable_skill->initMediaSource();
    }

    // available game modes
    modes["02p"] = tr("2 players");
    //modes["02pbb"] = tr("2 players (using blance beam)");
    modes["02_1v1"] = tr("2 players (KOF style)");
    modes["03p"] = tr("3 players");
    modes["04p"] = tr("4 players");
    modes["04_1v3"] = tr("4 players (Hulao Pass)");
    modes["05p"] = tr("5 players");
    modes["05_2v3"] = tr("5 players (Changban Slope)");
    modes["06p"] = tr("6 players");
    modes["06pd"] = tr("6 players (2 renegades)");
    modes["06_3v3"] = tr("6 players (3v3)");
    modes["07p"] = tr("7 players");
    modes["08p"] = tr("8 players");
    modes["08pd"] = tr("8 players (2 renegades)");
    modes["08pz"] = tr("8 players (0 renegade)");
    modes["08same"] = tr("8 players (same mode)");
    modes["09p"] = tr("9 players");
    modes["10pd"] = tr("10 players");
    modes["10p"] = tr("10 players (1 renegade)");
    modes["10pz"] = tr("10 players (0 renegade)");

    connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(deleteLater()));

    QString error_msg;
    lua = createLuaState(false, error_msg);
    if(lua == NULL){
        QMessageBox::warning(NULL, tr("Lua script error"), error_msg);
        exit(1);
    }

    foreach(QString ban, getBanPackages()){
        addBanPackage(ban);
    }
Exemplo n.º 12
0
void Engine::addScenario(Scenario *scenario){
    scenarios.insert(scenario->objectName(), scenario);

    addPackage(scenario);
}
Exemplo n.º 13
0
Engine::Engine()
{
    Sanguosha = this;

    lib = new QLibrary(qApp->applicationFilePath(), this);
    if(!lib->load()){
        qWarning("Package can not be loaded \n Error string: %s", qPrintable(lib->errorString()));
        exit(1);
    }

    QStringList package_names;
    package_names << "Standard"
                  << "Wind"
                  << "Fire"
                  << "Thicket"
                  << "Mountain"
                  << "God"
                  << "SP"
                  << "YJCM"
                  << "BGM"
                  << "Yitian"
                  << "Wisdom"
                  << "Test"

                  << "StandardCard"
                  << "StandardExCard"
                  << "Maneuvering"
                  << "SPCard"
                  << "YitianCard"
                  << "Nostalgia"
                  << "Joy"
                  << "Disaster"
                  << "JoyEquip";

    foreach(QString name, package_names)
        addPackage(name);

    QStringList scene_names;
    scene_names << "GuanduScenario"
                << "FanchengScenario"
                << "CoupleScenario"
                << "ZombieScenario"
                << "ImpasseScenario"
                << "CustomScenario";

    for(int i=1; i<=20; i++){
        scene_names << QString("MiniScene_%1").arg(i, 2, 10, QChar('0'));
    }

    foreach(QString name, scene_names)
        addScenario(name);

    // available game modes
    modes["02p"] = tr("2 players");
    //modes["02pbb"] = tr("2 players (using blance beam)");
    modes["02_1v1"] = tr("2 players (KOF style)");
    modes["03p"] = tr("3 players");
    modes["04p"] = tr("4 players");
    modes["04_1v3"] = tr("4 players (Hulao Pass)");
    modes["05p"] = tr("5 players");
    modes["06p"] = tr("6 players");
    modes["06pd"] = tr("6 players (2 renegades)");
    modes["06_3v3"] = tr("6 players (3v3)");
    modes["07p"] = tr("7 players");
    modes["08p"] = tr("8 players");
    modes["08pd"] = tr("8 players (2 renegades)");
    modes["08same"] = tr("8 players (same mode)");
    modes["09p"] = tr("9 players");
    modes["10p"] = tr("10 players");

    connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(deleteLater()));

    QString error_msg;
    lua = createLuaState(false, error_msg);
    if(lua == NULL){
        QMessageBox::warning(NULL, tr("Lua script error"), error_msg);
        exit(1);
    }

    foreach(QString ban, getBanPackages()){
        addBanPackage(ban);
    }
Exemplo n.º 14
0
Engine::Engine()
{
    Sanguosha = this;

    addPackage(NewStandard());
    addPackage(NewWind());
    addPackage(NewFire());
    addPackage(NewThicket());
    addPackage(NewMountain());
    addPackage(NewGod());
    addPackage(NewSP());
    addPackage(NewYJCM());
    addPackage(NewYitian());
    // addPackage(NewWisdom());
    addPackage(NewTest());

    addPackage(NewStandardCard());
    addPackage(NewStandardExCard());
    addPackage(NewManeuvering());
    addPackage(NewYitianCard());
    addPackage(NewNostalgia());
    addPackage(NewJoy());
    addPackage(NewDisaster());
    addPackage(NewJoyEquip());

    addScenario(NewGuanduScenario());
    addScenario(NewFanchengScenario());
    addScenario(NewCoupleScenario());
    addScenario(NewHongyanScenario());
    addScenario(NewZombieScenario());
    addScenario(NewLegendScenario());
    addScenario(NewImpasseScenario());

    // available game modes
    modes["02p"] = tr("2 players");
    //modes["02pbb"] = tr("2 players (using blance beam)");
    modes["02_1v1"] = tr("2 players (KOF style)");
    modes["03p"] = tr("3 players");
    modes["04p"] = tr("4 players");
    modes["04_1v3"] = tr("4 players (Hulao Pass)");
    modes["05p"] = tr("5 players");
    modes["06p"] = tr("6 players");
    modes["06pd"] = tr("6 players (2 renegades)");
    modes["06_3v3"] = tr("6 players (3v3)");
    modes["07p"] = tr("7 players");
    modes["08p"] = tr("8 players");
    modes["08pd"] = tr("8 players (2 renegades)");
    modes["08boss"] = tr("8 players (boss mode)");
    modes["08same"] = tr("8 players (same mode)");
    modes["09p"] = tr("9 players");
    modes["10p"] = tr("10 players");

    //challenge_mode_set = NULL;
    challenge_mode_set = new ChallengeModeSet(this);
    //addPackage(challenge_mode_set);

    translations.insert("bossmode", tr("Boss mode"));

    connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(deleteLater()));

    QString error_msg;
    lua = createLuaState(false, error_msg);
    if(lua == NULL){
        QMessageBox::warning(NULL, tr("Lua script error"), error_msg);
        exit(1);
    }
}
Exemplo n.º 15
0
void
WorkflowTest::testDefaultWorkflow()
{
    // TODO: init/begin/end trans

    // STEP 1: create transaction object
    SwdbPrivate::Transaction trans(conn);
    CPPUNIT_ASSERT(trans.getDone() == false);

    // STEP 2: set vars
    trans.setReleasever("26");

    // populate goal
    // resolve dependencies
    // prepare RPM transaction

    // STEP 3: associate RPMs to the transaction
    // bash-4.4.12-5.fc26.x86_64
    auto rpm_bash = std::make_shared< RPMItem >(conn);
    rpm_bash->setName("bash");
    rpm_bash->setEpoch(0);
    rpm_bash->setVersion("4.4.12");
    rpm_bash->setRelease("5.fc26");
    rpm_bash->setArch("x86_64");
    std::string repoid = "base";
    TransactionItemAction action = TransactionItemAction::INSTALL;
    TransactionItemReason reason = TransactionItemReason::GROUP;
    trans.addItem(rpm_bash, repoid, action, reason);

    // systemd-233-6.fc26
    auto rpm_systemd = std::make_shared< RPMItem >(conn);
    rpm_systemd->setName("systemd");
    rpm_systemd->setEpoch(0);
    rpm_systemd->setVersion("233");
    rpm_systemd->setRelease("6.fc26");
    rpm_systemd->setArch("x86_64");
    repoid = "base";
    action = TransactionItemAction::OBSOLETE;
    reason = TransactionItemReason::USER;
    auto ti_rpm_systemd = trans.addItem(rpm_systemd, repoid, action, reason);

    // sysvinit-2.88-14.dsf.fc20
    auto rpm_sysvinit = std::make_shared< RPMItem >(conn);
    rpm_sysvinit->setName("sysvinit");
    rpm_sysvinit->setEpoch(0);
    rpm_sysvinit->setVersion("2.88");
    rpm_sysvinit->setRelease("14.dsf.fc20");
    rpm_sysvinit->setArch("x86_64");
    repoid = "f20";
    action = TransactionItemAction::OBSOLETED;
    reason = TransactionItemReason::USER;
    auto ti_rpm_sysvinit = trans.addItem(rpm_sysvinit, repoid, action, reason);
    ti_rpm_sysvinit->addReplacedBy(ti_rpm_systemd);

    auto comps_group_core = std::make_shared< CompsGroupItem >(conn);
    comps_group_core->setGroupId("core");
    comps_group_core->setName("Core");
    comps_group_core->setTranslatedName("Úplný základ");
    comps_group_core->addPackage("bash", true, CompsPackageType::MANDATORY);
    repoid = "";
    action = TransactionItemAction::INSTALL;
    reason = TransactionItemReason::USER;
    trans.addItem(comps_group_core, repoid, action, reason);

    auto comps_environment_minimal = std::make_shared< CompsEnvironmentItem >(conn);
    comps_environment_minimal->setEnvironmentId("minimal");
    comps_environment_minimal->setName("Minimal");
    comps_environment_minimal->setTranslatedName("mmm");
    comps_environment_minimal->addGroup("core", true, CompsPackageType::MANDATORY);
    repoid = "";
    action = TransactionItemAction::INSTALL;
    reason = TransactionItemReason::USER;
    trans.addItem(comps_environment_minimal, repoid, action, reason);

    // STEP 4: save transaction and all associated items
    trans.begin();

    // STEP 5: run RPM transaction; callback: mark completed items
    for (auto i : trans.getItems()) {
        i->setDone(true);
        i->save();
    }

    // STEP 6
    // mark completed transaction
    trans.finish(true);
    CPPUNIT_ASSERT(trans.getDone() == true);

    // VERIFY
    // verify that data is available via public API
    auto trans2 = libdnf::Transaction(conn, trans.getId());
    CPPUNIT_ASSERT(trans2.getDone() == true);

    CPPUNIT_ASSERT(trans2.getItems().size() == 5);

    for (auto i : trans2.getItems()) {
        if (i->getId() == 1) {
            CPPUNIT_ASSERT(i->getAction() == TransactionItemAction::INSTALL);
            CPPUNIT_ASSERT(i->getReason() == TransactionItemReason::GROUP);
            CPPUNIT_ASSERT(i->getRepoid() == "base");
        } else if (i->getId() == 2) {
            CPPUNIT_ASSERT(i->getAction() == TransactionItemAction::OBSOLETE);
            CPPUNIT_ASSERT(i->getReason() == TransactionItemReason::USER);
            CPPUNIT_ASSERT(i->getRepoid() == "base");
        } else if (i->getId() == 3) {
            CPPUNIT_ASSERT(i->getAction() == TransactionItemAction::OBSOLETED);
            CPPUNIT_ASSERT(i->getReason() == TransactionItemReason::USER);
            CPPUNIT_ASSERT(i->getRepoid() == "f20");
        }

        // CPPUNIT_ASSERT(i->getItem()->getItemType() == "rpm");
        CPPUNIT_ASSERT(i->getDone() == true);
        // std::cout << "TransactionItem: " << i->getItem()->toStr() << std::endl;
        if (i->getItem()->getItemType() == ItemType::GROUP) {
            auto grp = std::dynamic_pointer_cast< CompsGroupItem >(i->getItem());
            CPPUNIT_ASSERT(grp->getPackages().size() == 1);
            for (auto i : grp->getPackages()) {
                // std::cout << "  CompsGroupPackage: " << i->getName() << std::endl;
            }
        }
        if (i->getItem()->getItemType() == ItemType::ENVIRONMENT) {
            auto env = std::dynamic_pointer_cast< CompsEnvironmentItem >(i->getItem());
            CPPUNIT_ASSERT(env->getGroups().size() == 1);
            for (auto i : env->getGroups()) {
                // std::cout << "  CompsEnvironmentGroup: @" << i->getGroupId() << std::endl;
            }
        }
    }
}