Ejemplo n.º 1
0
void Chusky::OnTimer(UINT_PTR nIDEvent)
{
	// TODO: 在此添加消息处理程序代码和/或调用默认值
	if (nIDEvent == 1){
		UpdateInsData();
	}
	if (nIDEvent == 2){
		UpdateMoney();
		UpdateDoneOrder();
		UpdateWaitOrder();
		UpdatePosition();
		traderHandler.getPosition();
	}
	CDialogEx::OnTimer(nIDEvent);
}
Ejemplo n.º 2
0
BOOL Chusky::OnInitDialog()
{
	CDialogEx::OnInitDialog();
	InitMarketDataList();
	InitWaitOrderList();
	InitDoneOrderList();
	InitTrader();
	InitTimer();
	UpdateInsData();
	UpdateMoney();

	if (!needLine){
		GetDlgItem(IDC_TREND_BUTTON)->EnableWindow(false);
		GetDlgItem(IDC_BUTTON)->EnableWindow(false);
	}
	return TRUE;  // return TRUE unless you set the focus to a control
	// 异常: OCX 属性页应返回 FALSE
}
Ejemplo n.º 3
0
/***********************************************************
show the GUI for a certain player
***********************************************************/
void ShopBoxHandler::ShowGUI(Ice::Long clientid, const LbaNet::PlayerPosition &curPosition,
					boost::shared_ptr<ShowGuiParamBase> params)
{
	ShowGuiParamBase * ptr = params.get();
	ShopParam * castedptr =
		static_cast<ShopParam *>(params.get());


	if(HasOpenedGui(clientid))
	{
		//close already opened box
		HideGUI(clientid);
	}
	else
	{
		if(_owner)
		{
			EventsSeq toplayer;
			GuiParamsSeq seq;
			seq.push_back(new ShopGuiParameter(castedptr->_shopinventory,
														castedptr->_currencyitem.IconName));
			toplayer.push_back(new RefreshGameGUIEvent(SynchronizedTimeHandler::GetCurrentTimeDouble(),
													"ShopBox", seq, true, false));

			toplayer.push_back(UpdateMoney((long)castedptr->_currencyitem.Id, (long)clientid));

			_owner->SendEvents((long)clientid, toplayer);
		}


		// add gui to the list to be removed later
		AddOpenedGui(clientid, curPosition);

		// store container info
		_openedshops[(long)clientid] = *castedptr;
	}

}
Ejemplo n.º 4
0
/***********************************************************
buy item
***********************************************************/
void ShopBoxHandler::BuyItem(long clientid, long ItemId)
{
	if(!_owner)
		return;

	int inventorysize = 0;
	LbaNet::ItemsMap inventory = _owner->GetInventory(clientid, inventorysize);
	ShopParam &ShopItems = _openedshops[clientid];



	// check if shop has listed items available
	LbaNet::ItemsMap::iterator itcont = ShopItems._shopinventory.find(ItemId);
	if(itcont != ShopItems._shopinventory.end())
	{
		// check if player has enough money
		LbaNet::ItemsMap::iterator itinv = inventory.find(ShopItems._currencyitem.Id);
		if(itinv != inventory.end())
		{
			bool buy = true;
			if(itinv->second.Count >= itcont->second.Info.BuyPrice)
			{
				LbaNet::ItemsMap::iterator itinv2 = inventory.find(ItemId);
				if(itinv2 != inventory.end())
				{
					// check if too much item of this type
					int diff = (itinv2->second.Info.Max - itinv2->second.Count);
					if(diff <= 0)
						buy = false;
				}
				else
				{
					if((int)inventory.size() >= inventorysize) // check if inventory full
						buy = false;
				}
			}
			else
			{
				buy = false;

				// send no kash message to chatbox
				LbaNet::GuiUpdatesSeq updseq;
				LbaNet::ChatTextUpdate * upd =
					new LbaNet::ChatTextUpdate("All", "info", "#106");
				updseq.push_back(upd);
				EventsSeq toplayer;
				toplayer.push_back(new LbaNet::UpdateGameGUIEvent(SynchronizedTimeHandler::GetCurrentTimeDouble(), "ChatBox", updseq));
				_owner->SendEvents(clientid, toplayer);
			}

			if(buy)
			{
				//update inventory
				LbaNet::ItemList Taken, Put;
				Taken[ShopItems._currencyitem.Id] = itcont->second.Info.BuyPrice;
				Put[ItemId] = 1;
				_owner->UpdateInventory(clientid, Taken, Put, LbaNet::InformChat);

				if(_owner)
				{
					EventsSeq toplayer;
					toplayer.push_back(UpdateMoney((long)ShopItems._currencyitem.Id, (long)clientid));
					_owner->SendEvents(clientid, toplayer);
				}
			}
		}
	}
}