Character::Character() {

    setName("Bro");
    setHealth(300);
    setAttack(25);
    setDefence(5);
    setMoney(10);

    mana = 300;

    facingRight = true;
    attackingRight = true;
    entityRect.h = 100;
    entityRect.w = 100;

    healthBar.x = 5;
    healthBar.y = 10;
    healthBar.w = 300;
    healthBar.h = 25;

    manaBar.x = 5;
    manaBar.y = 40;
    manaBar.w = 300;
    manaBar.h = 25;


}
Example #2
0
bool G::CostMoney(int moneyCost){
    if (moneyCost>getMoney()) {
        return false;
    }
    setMoney(getMoney()-moneyCost);
    return true;
}
Example #3
0
File: buy.cpp Project: B-Rich/mana
void BuyDialog::action(const gcn::ActionEvent &event)
{
    if (event.getId() == "quit")
    {
        close();
        return;
    }

    int selectedItem = mShopItemList->getSelected();

    // The following actions require a valid selection
    if (selectedItem < 0 ||
            selectedItem >= (int) mShopItems->getNumberOfElements())
    {
        return;
    }

    if (event.getId() == "slider")
    {
        mAmountItems = (int) mSlider->getValue();
        updateButtonsAndLabels();
    }
    else if (event.getId() == "inc" && mAmountItems < mMaxItems)
    {
        mAmountItems++;
        mSlider->setValue(mAmountItems);
        updateButtonsAndLabels();
    }
    else if (event.getId() == "dec" && mAmountItems > 1)
    {
        mAmountItems--;
        mSlider->setValue(mAmountItems);
        updateButtonsAndLabels();
    }
    else if (event.getId() == "max")
    {
        mAmountItems = mMaxItems;
        mSlider->setValue(mAmountItems);
        updateButtonsAndLabels();
    }
    // TODO: Actually we'd have a bug elsewhere if this check for the number
    // of items to be bought ever fails, Bertram removed the assertions, is
    // there a better way to ensure this fails in an _obvious_ way in C++?
    else if (event.getId() == "buy" && mAmountItems > 0 &&
                mAmountItems <= mMaxItems)
    {
        Net::getNpcHandler()->buyItem(mNpcId,
                                      mShopItems->at(selectedItem)->getId(),
                                      mAmountItems);

        // Update money and adjust the max number of items that can be bought
        mMaxItems -= mAmountItems;
        int price = mShopItems->at(selectedItem)->getPrice();
        if (price < 0)
            price = 0;
        setMoney(mMoney - mAmountItems * price);
        valueChanged(gcn::SelectionEvent(mShopItemList));
    }
}
Example #4
0
void LayerBaCayAvatar::resetAll()
{
	setFlag(kuser0, false);
	setFlag(kuser1, false);
	setFlag(kuser2, false);
	setFlag(kuser3, false);
    setFlag(kuser4, false);
    setFlag(kuser5, false);
    setFlag(kuser6, false);

	setName(kuser0, "");
	setName(kuser1, "");
	setName(kuser2, "");
	setName(kuser3, "");
    setName(kuser4, "");
    setName(kuser5, "");
    setName(kuser6, "");

	setMoney(kuser0, "");
	setMoney(kuser1, "");
	setMoney(kuser2, "");
	setMoney(kuser3, "");
    setMoney(kuser4, "");
    setMoney(kuser5, "");
    setMoney(kuser6, "");

	this->getUserByPos(kuser1)->setVisibleLayerInvite(true);
	this->getUserByPos(kuser2)->setVisibleLayerInvite(true);
	this->getUserByPos(kuser3)->setVisibleLayerInvite(true);
    this->getUserByPos(kuser4)->setVisibleLayerInvite(true);
    this->getUserByPos(kuser5)->setVisibleLayerInvite(true);
    this->getUserByPos(kuser6)->setVisibleLayerInvite(true);
}
Example #5
0
void BuyDialog::reset()
{
    mShopItems->clear();
    mShopItemList->adjustSize();

    // Reset previous selected items to prevent failing asserts
    mShopItemList->setSelected(-1);
    mSlider->setValue(0);

    setMoney(0);
}
Example #6
0
void BuyDialog::updateSlider(const int selectedItem)
{
    // Update money and adjust the max number of items
    // that can be bought
    mMaxItems -= mAmountItems;
    setMoney(mMoney - mAmountItems * mShopItems->at(selectedItem)->getPrice());

    // Reset selection
    mAmountItems = 1;
    mSlider->setScale(1, mMaxItems);
    mSlider->setValue(1);
}
Example #7
0
void TradeWindow::reset()
{
    mMyInventory->clear();
    mPartnerInventory->clear();
    mOkOther = false;
    mOkMe = false;
    setMoney(0);
    mMoneyField->setEnabled(true);
    mMoneyField->setText("");
    mAddButton->setEnabled(true);
    mMoneyChangeButton->setEnabled(true);
    setStatus(PREPARING);
}
//Dragon class
Dragon::Dragon(string name, int health, int attack, int defence, int money) {

    setName(name);
    setHealth(health);
    setAttack(attack);
    setDefence(defence);
    setMoney(money);

    entityRect.x = 0;
    entityRect.y = 0;
    entityRect.h = 100;
    entityRect.w = 100;
}
bool EnemyTest::init()
{
	if (!Sprite::init())
	{
		return false;
	}
	instance = GameManager::getInstance();

	sprite = Sprite::create("monster/monster1/right1.png"); //怪物本身的图片,初始化显示
	addChild(sprite);
	
	iceSprite = Sprite::create("ice.png"); //冰块图片
	iceSprite->setPosition(sprite->getPosition());
	addChild(iceSprite, 2);
	iceSprite->setVisible(false);

	setType(1);//这是第一种敌人
	setIsVisible(true);
	setRunSpeed(3);
	setHpPercentage(100);
	setMoney(2);//只值2元钱
	animationRight = createAnimation("monster/monster1/right", 4, 0.1f,95,84);
	AnimationCache::getInstance()->addAnimation(animationRight, "monster1_right");  //这个cache里存有各种做好的动画,重要,以便后来取出用动画
	animationLeft = createAnimation("monster/monster1/left", 4, 0.1f,95,84);
	AnimationCache::getInstance()->addAnimation(animationLeft, "monster1_left");
	

	createAndSetHpBar();

	schedule(schedule_selector(EnemyTest::changeDirection), 0.4f);
	schedule(schedule_selector(EnemyTest::deFroze), 0.2f); //每隔0.2秒执行一次检测是否减速函数

	////设置schduler来减缓敌人速度
	//CCScheduler *defaultScheduler = CCDirector::sharedDirector()->getScheduler();
	//// Create a new scheduler, and link it to the main scheduler
	//sched1 = new CCScheduler();
	//defaultScheduler->scheduleUpdateForTarget(sched1, 0, false);
	//// Create a new ActionManager, and link it to the new scheudler
	//actionManager1 = new CCActionManager();
	//sched1->scheduleUpdateForTarget(actionManager1, 0, false);
	//// Replace the default ActionManager with the new one.
	//this->setActionManager(actionManager1);

	return true;
}
Example #10
0
void TradeWindow::reset()
{
    mMyInventory->clear();
    mPartnerInventory->clear();
    mOkOther = false;
    mOkMe = false;
    setMoney(0);
    mMoneyField->setEnabled(true);
    mMoneyField->setText("");
    mMoneyLabel->setForegroundColorAll(getThemeColor(
        static_cast<int>(Theme::LABEL)), getThemeColor(
        static_cast<int>(Theme::LABEL_OUTLINE)));
    mAddButton->setEnabled(true);
    mMoneyChangeButton->setEnabled(true);
    mGotMoney = 0;
    mGotMaxMoney = 0;
    setStatus(PREPARING);
}
bool EnemyDisableTower::init() /*override*/
{
	if (!Sprite::init())
	{
		return false;
	}
	instance = GameManager::getInstance();

	sprite = Sprite::create("monster/monster_disable_tower/right1.png"); //怪物本身的图片,初始化显
	addChild(sprite);

	iceSprite = Sprite::create("ice.png"); //冰块图片
	iceSprite->setPosition(sprite->getPosition());
	addChild(iceSprite, 2);
	iceSprite->setVisible(false);

	disableRing = Sprite::create("disableRing.png");
	disableRing->setScale(2);
	addChild(disableRing, 10);
	auto fo = FadeOut::create(1);
	disableRing->runAction(RepeatForever::create(Sequence::create(fo, fo->reverse(), NULL)));

	setType(3);//这是第3种敌人
	setIsVisible(true);//不是隐形单位
	setRunSpeed(4);
	setHpPercentage(100);
	setMoney(8);//只值4元钱
	animationRight = createAnimation("monster/monster_disable_tower/right", 4, 0.1f, 100, 100);
	AnimationCache::getInstance()->addAnimation(animationRight, "monster_disable_right");  //这个cache里存有各种做好的动画,重要,以便后来取出用动画
	animationLeft = createAnimation("monster/monster_disable_tower/left", 4, 0.1f, 100, 100);
	AnimationCache::getInstance()->addAnimation(animationLeft, "monster_disable_left");


	createAndSetHpBar();

	schedule(schedule_selector(EnemyDisableTower::changeDirection), 0.4f);
	schedule(schedule_selector(EnemyDisableTower::deFroze), 0.2f); //每隔0.2秒执行一次检测是否减速函数
	//schedule(schedule_selector(EnemyDisableTower::disableNearbyTower), 0.2f);//每隔0.2秒沉默敌人一次,有问题:不能在敌人这判断,要在炮塔那判断才行,否则会图片会闪烁


	return true;
}
Example #12
0
Raider* Raider::createMonster(std::vector<Point> points)
{
    auto monster = new Raider();
    if (monster && monster->init())
    {
        monster->setPointsVector(points);
		monster->setMaxHp(160);
		monster->setCurrHp(160);
		monster->setMoney(30);
		monster->setRunSpeed(40);
		monster->setArmor(10);
		monster->setForce(8);
		monster->setAttackBySoldier(true);
        monster->runNextPoint();       
        monster->autorelease();
        return monster;
    }
    CC_SAFE_DELETE(monster);
    return NULL;
}
//Spider class
Spider::Spider() {

    setName("spider");
    setHealth(100);
    setAttack(10);
    setDefence(5);
    setMoney(10);

    facingRight = false;
    attackingRight = false;

    attackRect.x = 1000;
    attackRect.y = 0;

    entityRect.x = 0;
    entityRect.y = 0;
    entityRect.h = 100;
    entityRect.w = 100;


}
Example #14
0
Quetzal* Quetzal::createMonster(std::vector<Point> points)
{
    auto monster = new Quetzal();
    if (monster && monster->init())
    {

        monster->setPointsVector(points);
		monster->setMaxHp(500);
		monster->setCurrHp(500);
		monster->setMoney(20);
		monster->setForce(45);
		monster->setArmor(10);
		monster->setAttackBySoldier(false);
		monster->setRunSpeed(60);
        monster->runNextPoint();       
        monster->autorelease();
        return monster;
    }
    CC_SAFE_DELETE(monster);
    return NULL;
}
Example #15
0
Gorilla* Gorilla::createMonster(std::vector<Point> points)
{
    auto monster = new Gorilla();
    if (monster && monster->init())
    {

        monster->setPointsVector(points);
		monster->setMaxHp(2500);
		monster->setCurrHp(2500);
		monster->setMoney(500);
		monster->setForce(60);
		monster->setArmor(0);
		monster->setAttackBySoldier(true);
		monster->setRunSpeed(30);
        monster->runNextPoint();       
        monster->autorelease();
        return monster;
    }
    CC_SAFE_DELETE(monster);
    return NULL;
}
Example #16
0
Wolf* Wolf::createMonster(std::vector<Point> points)
{
    auto monster = new Wolf();
    if (monster && monster->init())
    {

        monster->setPointsVector(points);
		monster->setMaxHp(35);
		monster->setCurrHp(35);
		monster->setRunSpeed(100);
        monster->runNextPoint();      
		monster->setMoney(20);
		monster->setArmor(0);
		monster->setForce(2);
		monster->setAttackBySoldier(true);
        monster->autorelease();
        return monster;
    }
	CC_SAFE_DELETE(monster);
    return NULL;
}
Example #17
0
Boss_Efreeti* Boss_Efreeti::createMonster(std::vector<Point> points,std::vector<std::vector<std::vector<Point>>> sonpath)
{
    auto monster = new Boss_Efreeti();
    if (monster && monster->init())
    {
        monster->setPointsVector(points);
		monster->setMaxHp(5550);
		monster->setCurrHp(5550);
		monster->setMoney(1500);
		monster->sonPath = sonpath;
		monster->setForce(50);
		monster->setArmor(10);
		monster->setAttackByTower(true);
		monster->setAttackBySoldier(true);
		monster->setRunSpeed(20);
        monster->runNextPoint();       
        monster->autorelease();
        return monster;
    }
    CC_SAFE_DELETE(monster);
    return NULL;
}
Example #18
0
Tremor* Tremor::createMonster(std::vector<Point> points)
{
    auto monster = new Tremor();
    if (monster && monster->init())
    {

        monster->setPointsVector(points);
		monster->setMaxHp(35);
		monster->setCurrHp(35);
		monster->setMoney(10);
		monster->setForce(4);
		monster->setArmor(0);
		monster->setForce(8);
		monster->setAttackByTower(false);
		monster->setAttackBySoldier(true);
		monster->setRunSpeed(50);
        monster->runNextPoint();       
        monster->autorelease();
        return monster;
    }
    CC_SAFE_DELETE(monster);
    return NULL;
}
local void setMoneyCommand(const char *command, const char *params, Player *p, const Target *target)
{
	int force = 0;
	int quiet = 0;
	char *next;
	char *message;
	int amount;

	while (params != NULL) //get the flags
	{
		if (strncmp(params, "-f", 2) == 0)
		{
			force = 1;
		}
		else if (strncmp(params, "-q", 2) == 0)
		{
			quiet = 1;
		}
		else
		{
			break;
		}

		params = strchr(params, ' ');
		if (params) //check so that params can still == NULL
		{
			params++; //we want *after* the space
		}
	}

	if (params == NULL)
	{
		chat->SendMessage(p, "Grantexp: invalid usage.");
		return;
	}

	amount = strtol(params, &next, 0);

	if (next == params)
	{
		chat->SendMessage(p, "Grantexp: bad amount.");
		return;
	}

	while (*next == ' ') next++; //remove whitespace before the message

	message = next;
	if (message[0] == '\0')
	{
		message = NULL;
	}

	//all the parsing is now complete

	if (target->type == T_PLAYER) //private command
	{
		Player *t = target->u.p;

		if (!force)
		{
			if (database->isLoaded(t))
			{
				int oldAmount = getMoney(t);
				mysql->Query(NULL, NULL, 0, "INSERT INTO hs_transactions (srcplayer, tgtplayer, action, amount) VALUES(#,#,#,#)",
					database->getPerPlayerData(p)->id,
					database->getPerPlayerData(t)->id,
					MONEY_TYPE_GRANT,
					amount - oldAmount);
				setMoney(t, amount, MONEY_TYPE_GRANT);     

				if (quiet)
				{
					chat->SendMessage(p, "Quietly set player %s's money to $%i (from %i).", t->name, amount, oldAmount);
				}
				else
				{
					if (message == NULL)
					{
						chat->SendMessage(t, "Your money was set to $%i.", amount);
					}
					else
					{
						chat->SendMessage(t, "Your money was set to $%i %s", amount, message);
					}

					chat->SendMessage(p, "Set player %s's money to $%i (from %i).", t->name, amount, oldAmount);
				}
			}
			else
			{
				chat->SendMessage(p, "Player %s has no data loaded.", t->name);
			}
		}
		else
		{
			chat->SendMessage(p, "Whoa there, bud. The -f is only for arena and freq messages.");
		}
	}
	else //not private
	{
		if (force)
		{
			LinkedList set = LL_INITIALIZER;
			Link *link;
			int count;
			
			pd->TargetToSet(target, &set);

			for (link = LLGetHead(&set); link; link = link->next)
			{
				Player *t = link->data;

				if (database->isLoaded(t))
				{
					mysql->Query(NULL, NULL, 0, "INSERT INTO hs_transactions (srcplayer, tgtplayer, action, amount) VALUES(#,#,#,#)",
						database->getPerPlayerData(p)->id,
						database->getPerPlayerData(t)->id,
						MONEY_TYPE_GRANT,
						amount - getMoney(t));

					setMoney(t, amount, MONEY_TYPE_GRANT);

					if (!quiet)
					{
						if (message == NULL)
						{
							chat->SendMessage(t, "Your money was set to $%i.", amount);
						}
						else
						{
							chat->SendMessage(t, "Your money was set to $%i %s", amount, message);
						}
					}
				}
				else
				{
					chat->SendMessage(p, "Player %s has no data loaded.", t->name);
				}
			}

			count = LLCount(&set);

			LLEmpty(&set);

			chat->SendMessage(p, "You set %i players money to $%i.", count, amount);
		}
		else
		{
			chat->SendMessage(p, "For typo safety, the -f must be specified for arena and freq targets.");
		}
	}
}
Example #20
0
void G::AddMoney(int moneyAdd){
    setMoney(getMoney()+moneyAdd);
}
Example #21
0
Chusky::Chusky(CWnd* pParent /*=NULL*/)
	: CDialogEx(Chusky::IDD, pParent)
	, m_directRadioGroup(0)
	, m_makeRadioGroup(0)
	, m_num_of_topic_edit(0)
	, m_price_of_topic_edit(0)
	, pThread(NULL)
{
	m_pChart = NULL;
	m_pCandleChart = NULL;
	FILE *userSelectFile;
	while(!(userSelectFile = fopen("userName.txt", "r")));
	int user;
	fscanf(userSelectFile, "%d", &user);
	fscanf(userSelectFile, "%d", &needLine);
	fclose(userSelectFile);
	strcpy(BrokerID, "1004");
	if (user == 0){
		strcpy(UserID, "0193755301");
		strcpy(Password, "b82c5d504683007ac12478e703b19531");
	}
	if (user == 1){
		strcpy(UserID, "0193755302");
		strcpy(Password, "bad4d60aef1a060441dbbe47977d0dd1");
	}
	if (user == 2){
		strcpy(UserID, "0193755303");
		strcpy(Password, "f99a47bd147441718d35939f1c38a766");
	}

	pUserApi = CUstpFtdcMduserApi::CreateFtdcMduserApi();
	CLoginHandler tempLoginHandler(pUserApi);
	loginHandler = tempLoginHandler;
	loginHandler.getIns(numOfIns, contracts);
	loginHandler.getData(InsData);
	pUserApi -> RegisterSpi(&loginHandler);
	if (needLine)
		pUserApi -> SubscribeMarketDataTopic(100, USTP_TERT_RESTART);
	else
		pUserApi -> SubscribeMarketDataTopic(100, USTP_TERT_QUICK);
	pUserApi -> RegisterFront("tcp://117.185.125.4:17199");
	pUserApi -> Init();

	pTraderApi = CUstpFtdcTraderApi::CreateFtdcTraderApi();
	CTraderHandler tempTraderHandler(pTraderApi);
	traderHandler = tempTraderHandler;
	pTraderApi -> RegisterSpi(&traderHandler);
	pTraderApi -> SubscribePrivateTopic(USTP_TERT_RESTART);
	pTraderApi -> SubscribePublicTopic(USTP_TERT_RESTART);
	pTraderApi -> RegisterFront("tcp://117.185.125.4:17198");
	pTraderApi -> Init();

	CUstpFtdcQryInvestorAccountField qryInvestorAccount;	
	strcpy(qryInvestorAccount.BrokerID, BrokerID);
	strcpy(qryInvestorAccount.InvestorID, UserID);
	strcpy(qryInvestorAccount.UserID, Password);
	++g_UserOrderLocalID;
	int loopTime = 0;
	while (!traderHandler.getStatus()){
		++loopTime;
		if (loopTime > 50000000) break;
	}
	if (loopTime > 50000000){
		MessageBox(CString("登陆系统失败,请检查网络是否通畅及是否在系统开放时间"), CString("登陆失败"), MB_OK);
		OnClose();
	}
	setMoney();
	g_UserOrderLocalID = traderHandler.getUserOrderLocalID();
}
Example #22
0
void Mechanoid::addMoney(float m)
{
    setMoney(getMoney() + m);
}
Example #23
0
void Player::muchCheat(){
  setMoney(getMoney() + 10000);
}
void BuyDialog::action(const gcn::ActionEvent &event)
{
    const std::string &eventId = event.getId();
    if (eventId == "quit")
    {
        close();
        return;
    }
    else if (eventId == "sort")
    {
        sort();
        if (mSortDropDown)
            config.setValue("buySortOrder", mSortDropDown->getSelected());
        return;
    }

    const int selectedItem = mShopItemList->getSelected();

    // The following actions require a valid selection
    if (selectedItem < 0 || selectedItem >= mShopItems->getNumberOfElements())
        return;

    if (eventId == "slider")
    {
        mAmountItems = static_cast<int>(mSlider->getValue());
        mAmountField->setValue(mAmountItems);
        updateButtonsAndLabels();
    }
    else if (eventId == "inc" && mAmountItems < mMaxItems)
    {
        mAmountItems++;
        mSlider->setValue(mAmountItems);
        mAmountField->setValue(mAmountItems);
        updateButtonsAndLabels();
    }
    else if (eventId == "dec" && mAmountItems > 1)
    {
        mAmountItems--;
        mSlider->setValue(mAmountItems);
        mAmountField->setValue(mAmountItems);
        updateButtonsAndLabels();
    }
    else if (eventId == "max")
    {
        mAmountItems = mMaxItems;
        mSlider->setValue(mAmountItems);
        mAmountField->setValue(mAmountItems);
        updateButtonsAndLabels();
    }
    else if (eventId == "amount")
    {
        mAmountItems = mAmountField->getValue();
        mSlider->setValue(mAmountItems);
        updateButtonsAndLabels();
    }
    else if (eventId == "buy" && mAmountItems > 0 && mAmountItems <= mMaxItems)
    {
        if (mNpcId == -2)
        {
            const ShopItem *const item = mShopItems->at(selectedItem);
            Net::getAdminHandler()->createItems(item->getId(),
                mAmountItems, item->getColor());
        }
        else if (mNpcId != -1)
        {
            const ShopItem *const item = mShopItems->at(selectedItem);
            Net::getNpcHandler()->buyItem(mNpcId, item->getId(),
                item->getColor(), mAmountItems);

            // Update money and adjust the max number of items
            // that can be bought
            mMaxItems -= mAmountItems;
            setMoney(mMoney -
                     mAmountItems * mShopItems->at(selectedItem)->getPrice());

            // Reset selection
            mAmountItems = 1;
            mSlider->setValue(1);
            mSlider->setScale(1, mMaxItems);
        }
        else if (tradeWindow)
        {
            const ShopItem *const item = mShopItems->at(selectedItem);
            if (item)
            {
                Net::getBuySellHandler()->sendBuyRequest(mNick,
                    item, mAmountItems);
                tradeWindow->addAutoMoney(mNick,
                    item->getPrice() * mAmountItems);
            }
        }
    }
}