2011-08-28 15:17:58 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2010-2011 OTClient <https://github.com/edubart/otclient>
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2011-08-15 16:11:24 +02:00
|
|
|
#ifndef GAME_H
|
|
|
|
#define GAME_H
|
|
|
|
|
2011-08-15 23:02:52 +02:00
|
|
|
#include "declarations.h"
|
|
|
|
#include <otclient/net/declarations.h>
|
2011-11-10 06:29:25 +01:00
|
|
|
#include <otclient/core/item.h>
|
2011-11-16 18:33:43 +01:00
|
|
|
#include <otclient/core/outfit.h>
|
2011-08-15 16:11:24 +02:00
|
|
|
|
|
|
|
class Game
|
|
|
|
{
|
|
|
|
public:
|
2011-08-30 17:12:57 +02:00
|
|
|
// login/logout related
|
2011-08-16 02:30:31 +02:00
|
|
|
void loginWorld(const std::string& account,
|
|
|
|
const std::string& password,
|
2011-08-26 20:00:22 +02:00
|
|
|
const std::string& worldHost, int worldPort,
|
2011-08-16 02:30:31 +02:00
|
|
|
const std::string& characterName);
|
2011-08-29 16:14:21 +02:00
|
|
|
void cancelLogin();
|
2011-08-30 01:20:30 +02:00
|
|
|
void logout(bool force);
|
|
|
|
void processLoginError(const std::string& error);
|
2011-08-29 20:38:01 +02:00
|
|
|
void processConnectionError(const boost::system::error_code& error);
|
2011-08-29 16:14:21 +02:00
|
|
|
void processLogin(const LocalPlayerPtr& localPlayer);
|
|
|
|
void processLogout();
|
2011-08-15 23:02:52 +02:00
|
|
|
|
2011-09-04 19:21:42 +02:00
|
|
|
void processTextMessage(int type, const std::string& message);
|
2011-11-10 06:29:25 +01:00
|
|
|
void processInventoryChange(int slot, const ItemPtr& item);
|
2011-08-30 17:12:57 +02:00
|
|
|
|
2011-08-28 18:02:26 +02:00
|
|
|
void walk(Otc::Direction direction);
|
|
|
|
void turn(Otc::Direction direction);
|
2011-11-03 17:26:17 +01:00
|
|
|
void talkChannel(int channelType, int channelId, const std::string& message);
|
|
|
|
void talkPrivate(int channelType, const std::string& receiver, const std::string& message);
|
2011-11-14 23:32:55 +01:00
|
|
|
void openOutfitWindow();
|
2011-11-16 18:33:43 +01:00
|
|
|
void setOutfit(const Outfit& outfit);
|
2011-08-17 06:45:55 +02:00
|
|
|
|
2011-08-15 23:02:52 +02:00
|
|
|
bool isOnline() { return m_online; }
|
2011-08-15 16:11:24 +02:00
|
|
|
|
2011-12-28 12:26:52 +01:00
|
|
|
void setServerBeat(int serverBeat) { m_serverBeat = serverBeat; }
|
|
|
|
int getServerBeat() { return m_serverBeat; }
|
|
|
|
|
2011-08-15 23:02:52 +02:00
|
|
|
LocalPlayerPtr getLocalPlayer() { return m_localPlayer; }
|
2011-08-16 02:30:31 +02:00
|
|
|
ProtocolGamePtr getProtocolGame() { return m_protocolGame; }
|
2011-08-15 16:11:24 +02:00
|
|
|
|
|
|
|
private:
|
2011-08-15 23:02:52 +02:00
|
|
|
LocalPlayerPtr m_localPlayer;
|
2011-08-15 16:11:24 +02:00
|
|
|
ProtocolGamePtr m_protocolGame;
|
|
|
|
bool m_online;
|
2011-12-28 12:26:52 +01:00
|
|
|
int m_serverBeat;
|
2011-08-15 16:11:24 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
extern Game g_game;
|
|
|
|
|
2011-08-15 23:02:52 +02:00
|
|
|
#endif
|