Beispiel #1
0
// *************************************************************************
// Handling of the events of the Buy Equipment form.
// *************************************************************************
Boolean BuyEquipmentFormHandleEvent( EventPtr eventP )
{
    Boolean handled = false;

	switch (eventP->eType) 
	{
		case frmOpenEvent:
		case frmUpdateEvent:
			DrawBuyEquipmentForm();
			handled = true;
			break;

		case ctlSelectEvent:
			if (eventP->data.ctlSelect.controlID >= BuyEquipmentBuy0Button &&
				eventP->data.ctlSelect.controlID < BuyEquipmentBuy0Button+MAXWEAPONTYPE)
			{
				BuyItem( Shiptype[Ship.Type].WeaponSlots, 
					Ship.Weapon, 
					BASEWEAPONPRICE( eventP->data.ctlSelect.controlID - BuyEquipmentBuy0Button ), 
					Weapontype[eventP->data.ctlSelect.controlID - BuyEquipmentBuy0Button].Name, 
					eventP->data.ctlSelect.controlID - BuyEquipmentBuy0Button );
			}

			if (eventP->data.ctlSelect.controlID >= BuyEquipmentBuy0Button+MAXWEAPONTYPE &&
				eventP->data.ctlSelect.controlID < BuyEquipmentBuy0Button+MAXWEAPONTYPE+MAXSHIELDTYPE)
			{
				BuyItem( Shiptype[Ship.Type].ShieldSlots, 
					Ship.Shield, 
					BASESHIELDPRICE( eventP->data.ctlSelect.controlID - BuyEquipmentBuy0Button - MAXWEAPONTYPE ), 
					Shieldtype[eventP->data.ctlSelect.controlID - BuyEquipmentBuy0Button - MAXWEAPONTYPE].Name, 
					eventP->data.ctlSelect.controlID - BuyEquipmentBuy0Button - MAXWEAPONTYPE );
			}

			if (eventP->data.ctlSelect.controlID >= BuyEquipmentBuy0Button+MAXWEAPONTYPE+MAXSHIELDTYPE &&
				eventP->data.ctlSelect.controlID < BuyEquipmentBuy0Button+MAXWEAPONTYPE+MAXSHIELDTYPE+MAXGADGETTYPE )
			{
				if (HasGadget( &Ship, eventP->data.ctlSelect.controlID - BuyEquipmentBuy0Button - MAXWEAPONTYPE - MAXSHIELDTYPE ) &&
					EXTRABAYS != eventP->data.ctlSelect.controlID - BuyEquipmentBuy0Button - MAXWEAPONTYPE - MAXSHIELDTYPE)
					FrmAlert( NoMoreOfItemAlert );
				else
				{
					BuyItem( Shiptype[Ship.Type].GadgetSlots, 
						Ship.Gadget, 
						BASEGADGETPRICE( eventP->data.ctlSelect.controlID - BuyEquipmentBuy0Button - MAXWEAPONTYPE - MAXSHIELDTYPE ), 
						Gadgettype[eventP->data.ctlSelect.controlID - BuyEquipmentBuy0Button - MAXWEAPONTYPE - MAXSHIELDTYPE].Name, 
						eventP->data.ctlSelect.controlID - BuyEquipmentBuy0Button - MAXWEAPONTYPE - MAXSHIELDTYPE );
				}
			}

			handled = true;
			break;

		default:
			break;
	}
	
	return handled;
}
//gets the MyOwnLogger pointer, and runs the simulation of the coffee shop
void Simulation::Run_Simulation(MyOwnLogger *logger){
	_logger= logger;
	Sort_Suppliers();
	ProdComponents_build();
	Build_Menu(false);
	double revenue= 0;
	double profit= 0;
	Customers *custs= new Customers();
	std::ifstream ifs (_eventFile.c_str());
	std::string *eventLineP= Read_Line_From_File(ifs);
	std::string eventLine= *eventLineP;
	delete eventLineP;
	while ("" != eventLine){
		std::string *eventP= split(eventLine, ",");
		std::string event= *eventP;
		delete eventP;
		if ("register" == event){
			const std::string *custNameP= split(eventLine, ",");
			const std::string custName= *custNameP;
			const std::string *favProdP= split(eventLine, ",");
			const std::string favProd= *favProdP;
			delete custNameP;
			delete favProdP;
			const std::string *isVipP= split(eventLine, ",");
			bool isVip= ("1" == (*isVipP));
			delete isVipP;
			custs->AddCustomer(custName, favProd, isVip);
			std::string message= "";
			if (isVip)
				message= "New Vip Costumer registered - " + custName + ", Favorite product - " + favProd + ".";
			else
				message= "New Regular Costumer registered - " + custName + ", Favorite product - " + favProd + ".";
			_logger->Log(message.c_str(), Poco::Message::PRIO_NOTICE);
		}
		else if ("purchase" == event){
			std::string *custImgP= split(eventLine, ",");
			std::string custImg= *custImgP;
			delete custImgP;
			revenue= revenue + BuyItem(*custs, custImg, profit);
		}
		else if ("supplier_change" == event){
			SupplierChange(eventLine);
			Build_Menu(true);
		}
		eventLineP= Read_Line_From_File(ifs);
		eventLine= *eventLineP;
		delete eventLineP;
	}
	std::ostringstream ss;
	ss << "The total revenue is " << revenue << ", while the total profit is " << profit;
	_logger->Log(ss.str(), Poco::Message::PRIO_WARNING);
	ifs.close();
	FaceDetection FD;
	FD.CreateCollage(*custs);
	delete custs;
}
Beispiel #3
0
void CUIBagWnd::AttachAddon(CUICellItem* itm, CSE_ALifeItemWeapon::EWeaponAddonState add_on, bool external){
	R_ASSERT(itm);
	CWeapon* wpn = (CWeapon*)itm->m_pData;	
	CUICellItem* add_itm = NULL;
	CUIWeaponCellItem* wpn_itm = smart_cast<CUIWeaponCellItem*>(itm);
	R_ASSERT(wpn_itm);

	switch (add_on){
		case CSE_ALifeItemWeapon::eWeaponAddonScope:
			add_itm = GetItemBySectoin(*wpn->GetScopeName());
			break;
		case CSE_ALifeItemWeapon::eWeaponAddonSilencer:			
			add_itm = GetItemBySectoin(*wpn->GetSilencerName());
			break;
		case CSE_ALifeItemWeapon::eWeaponAddonGrenadeLauncher:	
			add_itm = GetItemBySectoin(*wpn->GetGrenadeLauncherName());		
			break;
		default:	NODEFAULT;
	}

	if (external)
        m_info[add_itm->m_index].external = external;
	BuyItem(add_itm);
	wpn->Attach((CInventoryItem*)add_itm->m_pData, true);

	wpn_itm->Update();

	if (external){
		switch (add_on){
			case CSE_ALifeItemWeapon::eWeaponAddonScope:
				SET_EXTERNAL_COLOR(wpn_itm->get_addon_static(CUIWeaponCellItem::eScope));
				break;
			case CSE_ALifeItemWeapon::eWeaponAddonSilencer:			
				SET_EXTERNAL_COLOR(wpn_itm->get_addon_static(CUIWeaponCellItem::eSilencer));
				break;
			case CSE_ALifeItemWeapon::eWeaponAddonGrenadeLauncher:	
				SET_EXTERNAL_COLOR(wpn_itm->get_addon_static(CUIWeaponCellItem::eLauncher));
				break;
			default:	
				NODEFAULT;
		}
	}
}
Beispiel #4
0
/***********************************************************
update gui with info from server
***********************************************************/
void ShopBoxHandler::Update(Ice::Long clientid, const LbaNet::GuiUpdateBasePtr &Update)
{
	LbaNet::GuiUpdateBase * ptr = Update.get();
	const std::type_info& info = typeid(*ptr);

	// LbaNet::BuyItemUpdate
	if(info == typeid(LbaNet::BuyItemUpdate))
	{
		LbaNet::BuyItemUpdate * castedptr =
			dynamic_cast<LbaNet::BuyItemUpdate *>(ptr);

		BuyItem((long)clientid, (long)castedptr->ItemId);
	}

	// LbaNet::GuiClosedUpdate
	if(info == typeid(LbaNet::GuiClosedUpdate))
	{
		HideGUI(clientid);
	}
}
void CShop::HandleCommands( const char *menuCommand, idUserInterface *gui ) {
	if( idStr::Icmp( menuCommand, "shopLoad" ) == 0 ) {
		// Clear out the shop
		Init();
		// get list of all items that can be sold
		LoadShopItemDefinitions();
		// init and update the shop GUI
		DisplayShop( gui );
		// refresh the display so items are greyed out
		gui->HandleNamedEvent( "UpdateItemColours" );
	} else if( idStr::Icmp( menuCommand, "shopBuy" ) == 0 ) {
		// Buy an item
		int boughtItem = gui->GetStateInt( "boughtItem", "0" );
		BuyItem( boughtItem );
		UpdateGUI( gui );
	} else if( idStr::Icmp( menuCommand, "shopSold" ) == 0 ) {
		// Return an item to the shelf
		int soldItem = gui->GetStateInt( "soldItem", "0" );
		SellItem( soldItem );
		UpdateGUI( gui );
	} else if( idStr::Icmp( menuCommand, "shopDropUndrop" ) == 0 ) {
		// Drop one of the starting items
		int dropItem = gui->GetStateInt( "dropItem", "0" );
		// Decide depending on the item if we should drop or undrop
		DropUndropItem( dropItem );
		UpdateGUI( gui );
	} else if( idStr::Icmp( menuCommand, "shopMore" ) == 0 ) {
		const char *listName = gui->GetStateString( "moreList", "" );
		if( idStr::Icmp( listName, "forSale" ) == 0 ) {
			_forSaleTop = ScrollList( _forSaleTop, LIST_SIZE_FOR_SALE, _itemsForSale );
		} else if( idStr::Icmp( listName, "starting" ) == 0 ) {
			_startingTop = ScrollList( _startingTop, LIST_SIZE_STARTING, _startingItems );
		} else if( idStr::Icmp( listName, "purchased" ) == 0 ) {
			_purchasedTop = ScrollList( _purchasedTop, LIST_SIZE_PURCHASED, _itemsPurchased );
		}
		UpdateGUI( gui );
	} else if( idStr::Icmp( menuCommand, "shopDone" ) == 0 ) {
		// The player is done shopping, now set up the starting equipment
		CopyPurchasedIntoStartingEquipment();
	}
}
Beispiel #6
0
void GStateScene::ShopInputEvent(GnInterface* pInterface, GnIInputEvent* pEvent)
{
	if( pEvent->GetEventType() == GnIInputEvent::PUSH )
	{
		if( pInterface->GetTegID() == GInterfaceLayer::LISTITEM_SHOP )
		{
			if( ViewItemExplain( mpCurrentShopItem, pInterface ) )
			{
				if( mpCurrentInvenItem )
					mpCurrentInvenItem->SetVisibleExplain( false );
				if( mpCurrentEquipItem )
					mpCurrentEquipItem->SetVisibleExplain( false );
			}
		}
		else if( pInterface->GetTegID() == GInterfaceLayer::LISTITEM_INVEN )
		{
			if( ViewItemExplain( mpCurrentInvenItem, pInterface ) )
			{
				if( mpCurrentShopItem )
					mpCurrentShopItem->SetVisibleExplain( false );
				if( mpCurrentEquipItem )
					mpCurrentEquipItem->SetVisibleExplain( false );
			}
		}
		else
		{
			if( ViewItemExplain( mpCurrentEquipItem, pInterface ) )
			{
				if( mpCurrentShopItem )
					mpCurrentShopItem->SetVisibleExplain( false );
				if( mpCurrentInvenItem )
					mpCurrentInvenItem->SetVisibleExplain( false );	
			}
		}
	}
	else if( pEvent->GetEventType() == GnIInputEvent::PUSHUP )
	{
		GStateUILayer* interfaceLayer = (GStateUILayer*)mpInterfaceLayer;
		switch( pInterface->GetTegID() )
		{
			case GInterfaceLayer::BT_BUY_ITEM:
				BuyItem( interfaceLayer->GetInventoryListCtrl(), interfaceLayer->GetEquipListCtrl()
					, interfaceLayer->GetMoneyLabel(), mpCurrentShopItem );
				break;
			case GInterfaceLayer::BT_SELL_ITEM:
				if( SellItem( interfaceLayer->GetInventoryListCtrl(), interfaceLayer->GetEquipListCtrl()
					, interfaceLayer->GetMoneyLabel(), mpCurrentInvenItem ) == 0 )
				{
					if( mpCurrentInvenItem )
					{
						mpCurrentInvenItem->SetVisibleExplain( false );
						mpCurrentInvenItem = NULL;
					}
				}
				break;
			case GInterfaceLayer::BT_EQUIP_ITEM:
				EquipItem( interfaceLayer->GetInventoryListCtrl(), interfaceLayer->GetEquipListCtrl()
					, mpCurrentInvenItem );
//				if( mpCurrentInvenItem )
//				{
//					mpCurrentInvenItem->SetVisibleExplain( false );
//					mpCurrentInvenItem = NULL;
//				}
				break;
			case GInterfaceLayer::BT_UNEQUIP_ITEM:
				UnEquipItem( interfaceLayer->GetInventoryListCtrl(), interfaceLayer->GetEquipListCtrl()
					, mpCurrentEquipItem );
				if( mpCurrentEquipItem )
				{
					mpCurrentEquipItem->SetVisibleExplain( false );
					mpCurrentEquipItem = NULL;
				}
				break;
		}	
	}
}
Beispiel #7
0
void BuySpark(void)
{
	BuyItem(ITEM_TYPE_LIGHTNING_SCROLL);
}
Beispiel #8
0
void BuyIcicle(void)
{
	BuyItem(ITEM_TYPE_ICE_SCROLL);
}
Beispiel #9
0
void BuyBomb(void)
{
	BuyItem(ITEM_TYPE_FIRE_SCROLL);
}
Beispiel #10
0
void BuyElixir(void)
{
	BuyItem(ITEM_TYPE_FULL_POTION);
}
Beispiel #11
0
void BuyPotion(void)
{
	BuyItem(ITEM_TYPE_POTION);
}