int getForIchiranContext(uiContext d) { forichiranContext fc; int retval = 0; if (pushCallback(d, d->modec, NO_CALLBACK, NO_CALLBACK, NO_CALLBACK, NO_CALLBACK) == 0) { #ifndef WIN jrKanjiError = "malloc (pushCallback) ¤Ç¤¤Þ¤»¤ó¤Ç¤·¤¿"; #else jrKanjiError = "malloc (pushCallback) \244\307\244\255\244\336\244\273\244\363\244\307\244\267\244\277"; /* ¤Ç¤¤Þ¤»¤ó¤Ç¤·¤¿ */ #endif return(NG); } if((fc = newForIchiranContext()) == NULL) { popCallback(d); return(NG); } fc->next = d->modec; d->modec = (mode_context)fc; fc->prevMode = d->current_mode; fc->majorMode = d->majorMode; return(retval); }
int getTourokuContext(uiContext d) { tourokuContext tc; int retval = 0; if (pushCallback(d, d->modec, NO_CALLBACK, NO_CALLBACK, NO_CALLBACK, NO_CALLBACK) == 0) { #ifndef WIN jrKanjiError = "malloc (pushCallback) ¤Ç¤¤Þ¤»¤ó¤Ç¤·¤¿"; #else jrKanjiError = "malloc (pushCallback) \244\307\244\255\244\336\244\273" "\244\363\244\307\244\267\244\277"; #endif return(NG); } if((tc = newTourokuContext()) == (tourokuContext)NULL) { popCallback(d); return(NG); } tc->majorMode = d->majorMode; tc->next = d->modec; d->modec = (mode_context)tc; tc->prevMode = d->current_mode; return(retval); }
InputHandler::InputHandler() { // Set the default callback function Callback_Type callback_temp = std::bind(&InputHandler::defaultCallback, this, std::placeholders::_1); pushCallback(callback_temp); State_Callback_Type state_callback_temp = std::bind(&InputHandler::defaultStateCallback, this); setStateCallback(state_callback_temp); }
void LuaAI::askForGuanxing(const QList<int> &cards, QList<int> &up, QList<int> &bottom, bool up_only) { lua_State *L = room->getLuaState(); pushCallback(L, __FUNCTION__); pushQIntList(L, cards); lua_pushboolean(L, up_only); int error = lua_pcall(L, 3, 2, 0); if (error) { reportError(L); return TrustAI::askForGuanxing(cards, up, bottom, up_only); } getTable(L, bottom); getTable(L, up); }
int LuaAI::askForAG(const QList<int> &card_ids, bool refusable, const QString &reason) { lua_State *L = room->getLuaState(); pushCallback(L, __FUNCTION__); pushQIntList(L, card_ids); lua_pushboolean(L, refusable); lua_pushstring(L, reason.toAscii()); int error = lua_pcall(L, 4, 1, 0); if (error) { reportError(L); return TrustAI::askForAG(card_ids, refusable, reason); } int card_id = lua_tointeger(L, -1); lua_pop(L, 1); return card_id; }
QList<int> LuaAI::askForDiscard(const QString &reason, int discard_num, int min_num, bool optional, bool include_equip) { lua_State *L = room->getLuaState(); pushCallback(L, __FUNCTION__); lua_pushstring(L, reason.toAscii()); lua_pushinteger(L, discard_num); lua_pushinteger(L, min_num); lua_pushboolean(L, optional); lua_pushboolean(L, include_equip); int error = lua_pcall(L, 6, 1, 0); if (error) { reportError(L); return TrustAI::askForDiscard(reason, discard_num, min_num, optional, include_equip); } QList<int> result; if (getTable(L, result)) return result; else return TrustAI::askForDiscard(reason, discard_num, min_num, optional, include_equip); }
QString LuaAI::askForUseCard(const QString &pattern, const QString &prompt, const Card::HandlingMethod method) { if (callback == 0) return TrustAI::askForUseCard(pattern, prompt, method); lua_State *L = room->getLuaState(); pushCallback(L, __FUNCTION__); lua_pushstring(L, pattern.toAscii()); lua_pushstring(L, prompt.toAscii()); lua_pushinteger(L, method); int error = lua_pcall(L, 4, 1, 0); const char *result = lua_tostring(L, -1); lua_pop(L, 1); if (error) { const char *error_msg = result; room->output(error_msg); return "."; } return result; }