void PathMachine::setCurrentRoom(const RoomId id, bool update) { Forced forced(lastEvent, update); emit lookingForRooms(forced, id); releaseAllPaths(); if (const Room *perhaps = forced.oneMatch()) { // WARNING: This copies the current values of the room. mostLikelyRoom = *perhaps; emit playerMoved(mostLikelyRoom.getPosition()); emit setCharPosition(mostLikelyRoom.getId()); state = PathState::APPROVED; } }
void MMapperPluginParser::mudOutput(const QString &text) { if (text.isEmpty()) return; if (text.startsWith('Y')) { qDebug() << "* MMapperPluginParser detected some text" << text; if (text.startsWith("You are dead!")) { queue.clear(); emit showPath(queue, true); emit releaseAllPaths(); return; } else if (text.startsWith("You failed to climb")) { if (!queue.isEmpty()) queue.dequeue(); queue.prepend(CID_NONE); emit showPath(queue, true); return; } else if (text.startsWith("You are too exhausted.")) { if (!queue.isEmpty()) queue.dequeue(); //queue.prepend(CID_NONE); emit showPath(queue, true); return; } /* else if (text.startsWith("You flee head")) { queue.enqueue(_move); } else if (text.startsWith("You follow")) { queue.enqueue(_move); return; } */ else if (text.startsWith("You quietly scout")) { queue.prepend(CID_SCOUT); return; } } }
void Parser::parseMudCommands(QString& str) { /*if (str.startsWith('B') && str.startsWith("Brief mode on")){ emit sendToMud((QByteArray)"brief\n"); }*/ if (str.startsWith('<') && str.startsWith("<xml>")) //we are in xml mode { emit setXmlMode(); emit sendToUser((QByteArray)"[MMapper] Mode ---> XML\n"); emptyQueue(); } if (str.startsWith('Y')) { if (str.startsWith("You are dead!")) { queue.clear(); emit showPath(queue, true); emit releaseAllPaths(); return; } if (str.startsWith("You flee")) { if (str.contains("north")) queue.enqueue(CID_NORTH); else if (str.contains("south")) queue.enqueue(CID_SOUTH); else if (str.contains("east")) queue.enqueue(CID_EAST); else if (str.contains("west")) queue.enqueue(CID_WEST); else if (str.contains("up")) queue.enqueue(CID_UP); else if (str.contains("down")) queue.enqueue(CID_DOWN); return; } if (str.startsWith("You now follow")){ m_following = true; emit sendToUser((QByteArray)"----> follow mode on.\n"); return; } else if (str.startsWith("You quietly scout")) { queue.prepend(CID_SCOUT); return; } if (m_following) { if (str=="You will not follow anyone else now.") { m_following = false; emit sendToUser((QByteArray)"----> follow mode off.\n"); return; } if (str.startsWith("You follow")) { switch (m_followDir) { case NORTH: queue.enqueue(CID_NORTH);break; case SOUTH: queue.enqueue(CID_SOUTH);break; case EAST: queue.enqueue(CID_EAST);break; case WEST: queue.enqueue(CID_WEST);break; case UP: queue.enqueue(CID_UP);break; case DOWN: queue.enqueue(CID_DOWN);break; case UNKNOWN: queue.enqueue(CID_NONE);break; } return; } } } if (m_following) { if(str.contains("leave")) { if ((str.contains("leaves north")) || (str.contains("leave north"))) m_followDir = NORTH; else if ((str.contains("leaves south")) || (str.contains("leave south"))) m_followDir = SOUTH; else if ((str.contains("leaves east")) || (str.contains("leave east"))) m_followDir = EAST; else if ((str.contains("leaves west")) || (str.contains("leave west"))) m_followDir = WEST; else if ((str.contains("leaves up")) || (str.contains("leave up"))) m_followDir = UP; else if ((str.contains("leaves down")) || (str.contains("leave down"))) m_followDir = DOWN; } } // parse regexps which cancel last char move if (Patterns::matchMoveCancelPatterns(str)) { if(!queue.isEmpty()) queue.dequeue(); emit showPath(queue, true); return; } // parse regexps which force new char move if (Patterns::matchMoveForcePatterns(str)) { queue.enqueue(CID_NONE); emit showPath(queue, true); return; } }
void MumeXmlParser::parseMudCommands(const QString &str) { if (str.at(0) == ('Y')) { if (str.startsWith("You are dead!")) { queue.clear(); emit showPath(queue, true); emit releaseAllPaths(); markCurrentCommand(); return; } else if (str.startsWith("You failed to climb")) { if (!queue.isEmpty()) queue.dequeue(); queue.prepend(CommandIdType::NONE); // REVISIT: Do we need this? emit showPath(queue, true); return; } else if (str.startsWith("You flee head")) { queue.enqueue(CommandIdType::LOOK); return; } else if (str.startsWith("You follow")) { queue.enqueue(CommandIdType::LOOK); return; } else if (str.startsWith("You need to swim to go there.") || str.startsWith("You cannot ride there.") || str.startsWith("You are too exhausted.") || str.startsWith("You are too exhausted to ride.") || str.startsWith("Your mount refuses to follow your orders!") || str.startsWith("You failed swimming there.") || str.startsWith("You can't go into deep water!")) { if (!queue.isEmpty()) queue.dequeue(); emit showPath(queue, true); return; } else if (str.startsWith("You quietly scout")) { queue.prepend(CommandIdType::SCOUT); return; } } else if (str.at(0) == 'T') { if (str.startsWith("The current time is")) { m_mumeClock->parseClockTime(str); // The door } else if (str.endsWith("seems to be closed.") // The (a|de)scent || str.endsWith("is too steep, you need to climb to go there.")) { if (!queue.isEmpty()) queue.dequeue(); emit showPath(queue, true); } } else if (str.at(0) == 'A') { if (str.startsWith("Alas, you cannot go that way...") // A pack horse || str.endsWith("is too exhausted.")) { if (!queue.isEmpty()) queue.dequeue(); emit showPath(queue, true); } } else if (str.at(0) == 'N') { if (str.startsWith("No way! You are fighting for your life!") || str.startsWith("Nah... You feel too relaxed to do that.")) { if (!queue.isEmpty()) queue.dequeue(); emit showPath(queue, true); } } else if (str.at(0) == 'M') { if (str.startsWith("Maybe you should get on your feet first?")) { if (!queue.isEmpty()) queue.dequeue(); emit showPath(queue, true); } } else if (str.at(0) == 'I') { if (str.startsWith("In your dreams, or what?")) { if (!queue.isEmpty()) queue.dequeue(); emit showPath(queue, true); } } else if (str.at(0) == 'Z') { // pack horse if (str.endsWith("doesn't want you riding him anymore.") // donkey || str.endsWith("doesn't want you riding her anymore.") // hungry warg || str.endsWith("doesn't want you riding it anymore.")) { if (!queue.isEmpty()) queue.dequeue(); emit showPath(queue, true); } } if (str.endsWith("of the Third Age.")) { m_mumeClock->parseMumeTime(str); } // Certain weather events happen on ticks if (m_readWeatherTag) { m_readWeatherTag = false; m_mumeClock->parseWeather(str); } }