13 Aug, 2015, wifidi wrote in the 1st comment:
Votes: 0
Here's a card guessing game that uses mob_prog's to call c++:

Comparing files MURK++\character.hpp and MURK++DEV\CHARACTER.HPP
***** MURK++\character.hpp
void do_mpforce(std::string argument);

***** MURK++DEV\CHARACTER.HPP
void do_mpforce(std::string argument);
void do_mpcardguess(std::string argument);

*****


commands.cpp modified look, oload; could be placed elsewhere
1489a1490
> if (obj->item_type == ITEM_TRASH) obj->value[2] = 1;
1495a1497
> if (obj->item_type == ITEM_TRASH) obj->value[2] = 1;
1510a1513
> if (obj->item_type == ITEM_TRASH) obj->value[2] = 1;
1516a1520
> if (obj->item_type == ITEM_TRASH) obj->value[2] = 1;
5429,5432c5433,5438
< for (rch = location->people.begin(); rch != location->people.end(); rch++) {
< buf1.append(" ");
< one_argument ((*rch)->name, tmp);
< buf1.append(buf);

> for (rch = location->people.begin(); rch != location->people.end(); /*rch++*/) {
> buf1.append(" ");
> buf1.append((*rch)->name);
> if (++rch != location->people.end()) buf1.append(",");
> //one_argument ((*rch)->name, tmp);
> //buf1.append(buf);
6038a6045,6079
> // if a playing card randomly set its rank and suit and set the card name
> if (!str_cmp(arg1, "24")) {
> pObjIndex->value[0] = number_range(1, 13); // suit
> pObjIndex->value[1] = number_range(1, 4); // value
> std::string rank, suit, keyword, cardname;
> rank =
> (pObjIndex->value[0] == 1) ? "Ace" :
> ((pObjIndex->value[0] == 2) ? "Two" :
> ((pObjIndex->value[0] == 3) ? "Three" :
> ((pObjIndex->value[0] == 4) ? "Four" :
> ((pObjIndex->value[0] == 5) ? "Five" :
> ((pObjIndex->value[0] == 6) ? "Six" :
> ((pObjIndex->value[0] == 7) ? "Seven" :
> ((pObjIndex->value[0] == 8) ? "Eight" :
> ((pObjIndex->value[0] == 9) ? "Nine" :
> ((pObjIndex->value[0] == 10) ? "Ten" :
> ((pObjIndex->value[0] == 11) ? "Jack" :
> ((pObjIndex->value[0] == 12) ? "Queen" :
> "King")))))))))));
> suit =
> (pObjIndex->value[1] == 1) ? "Spades" :
> ((pObjIndex->value[1] == 2) ? "Hearts" :
> ((pObjIndex->value[1] == 3) ? "Clubs" :
> "Diamonds"));
> char buf[MAX_STRING_LENGTH];
> snprintf(buf, sizeof buf, "The %s of %s", rank.c_str(), suit.c_str());
> cardname.append(buf);
> keyword = "card";
> pObjIndex->extra_descr.clear();
> ExtraDescription* ed = new ExtraDescription();
> ed->keyword = keyword;
> ed->description = cardname;
> pObjIndex->extra_descr.push_back(ed);
> }
>
6039a6081


Comparing files MURK++\limbo.are and MURK++DEV\LIMBO.ARE
***** MURK++\limbo.are
1 0 0
#0
***** MURK++DEV\LIMBO.ARE
1 0 0
#24
card playing~
a playing card~
A playing card is here.~
~
13 64 1|16384
0 0 0 0
1 0 0
E
card~
The face of this card is blank.
~
#25
card playing~
a playing card~
A playing card is here.~
~
13 0 1|16384
0 0 0 0
1 0 0
E
card~
The face of this card is blank.
~
#0
*****


Comparing files MURK++\midgaard.are and MURK++DEV\MIDGAARD.ARE
***** MURK++\midgaard.are
M 3144 crier.prg
S
***** MURK++DEV\MIDGAARD.ARE
M 3144 crier.prg
M 3012 card_color_or_suit_guess.prg
M 3012 card_named_is_red.prg
M 3012 card_named_is_black.prg
S
*****


murk.cpp
526c526,527
<

> {"mpcardguess", &Character::do_mpcardguess, POS_DEAD, 41 },
>
6136a6138,6316
> }
>
> void Character::do_mpcardguess(std::string argument)
> {
> std::string arg1, arg2, arg3;
>
> argument = one_argument(argument, arg1);
> argument = one_argument(argument, arg2);
> argument = one_argument(argument, arg3);
>
> if (!is_npc()) {
> send_to_char("Huh?\r\n");
> return;
> }
>
> Object *obj;
> ObjIter o = carrying.begin();
> obj = *o;
>
> if (!can_see_obj(obj)) return;
>
> enum suits { BLANK, SPADE, HEART, CLUB, DIAMOND };
>
> int suit = (*o)->value[1];
>
> if (suit < SPADE || suit > DIAMOND) return;
>
> if (arg1.empty() && arg2.empty() && arg3.empty()) {
> act((SPADE == suit) ? "$n says, 'Guess'." :
> ((HEART == suit) ? "$n asks, 'Color?'." :
> ((CLUB == suit) ? "$n asks, 'What color?'." :
> "$n says, 'Guess the color'.")), NULL, NULL, TO_ROOM);
> return;
> }
>
> int rank = (*o)->value[0];
> if (rank < 1 || rank > 13) return;
>
> if (!str_cmp(arg1, "black")) {
> (suit == SPADE || suit == CLUB) ?
> act((rank >= 1 && rank <= 4) ? "$n replies, 'yes'." :
> ((rank >= 5 && rank <= 8) ? "$n replies, 'correct'." :
> ((rank >= 5 && rank <= 12) ? "$n replies, 'yes it is'." :
> "$n asks, 'Is it a spade or a club'?")), NULL, NULL, TO_ROOM)
> :
> act((rank >= 1 && rank <= 4) ? "$n replies, 'red'." :
> ((rank >= 5 && rank <= 8) ? "$n replies, 'not black'." :
> ((rank >= 5 && rank <= 12) ? "$n replies, 'no, it's red'." :
> "$n states, 'no, it's a red card'.")), NULL, NULL, TO_ROOM);
> return;
> }
>
> if (!str_cmp(arg1, "red")) {
> (suit == HEART || suit == DIAMOND) ?
> act((rank >= 1 && rank <= 4) ? "$n replies, 'yes'." :
> ((rank >= 5 && rank <= 8) ? "$n replies, 'correct'." :
> ((rank >= 5 && rank <= 12) ? "$n replies, 'yes it is'." :
> "$n asks, 'Is it a heart or a diamond'?")), NULL, NULL, TO_ROOM)
> :
> act((rank >= 1 && rank <= 4) ? "$n replies, 'black'." :
> ((rank >= 5 && rank <= 8) ? "$n replies, 'not red'." :
> ((rank >= 5 && rank <= 12) ? "$n replies, 'no, it's black'." :
> "$n states, 'no, it's a black card'.")), NULL, NULL, TO_ROOM);
> return;
> }
>
> if (!str_cmp(arg1, "spade")) {
> (suit == SPADE) ?
> act((rank >= 1 && rank <= 4) ? "$n replies, 'yes!'." :
> ((rank >= 5 && rank <= 8) ? "$n replies, 'correct!'." :
> ((rank >= 5 && rank <= 12) ? "$n replies, 'yes it is!'." :
> "$n exclaims, 'Is it a spade!'.")), NULL, NULL, TO_ROOM)
> :
> act((rank >= 1 && rank <= 4) ? "$n replies, 'no'." :
> ((rank >= 5 && rank <= 8) ? "$n replies, 'it's not'." :
> ((rank >= 5 && rank <= 12) ? "$n replies, 'no, it's not'." :
> "$n states, 'it's not a spade'.")), NULL, NULL, TO_ROOM);
> return;
> }
>
> if (!str_cmp(arg1, "heart")) {
>
> if (suit == HEART) {
> if (rank == 1 || rank == 5 || rank == 9 || rank == 13)
> act("$n replies, 'yes!'.", NULL, NULL, TO_ROOM);
> else if (rank == 2 || rank == 6 || rank == 10)
> act("$n replies, 'it is!'.", NULL, NULL, TO_ROOM);
> else if (rank == 3 || rank == 7 || rank == 11)
> act("$n replies, 'yes it is!'.", NULL, NULL, TO_ROOM);
> else if (rank == 4 || rank == 8 || rank == 12)
> act("$n replies, 'it is a heart!'.", NULL, NULL, TO_ROOM);
> }
> else {
> if (rank == 1 || rank == 5 || rank == 9 || rank == 13)
> act("$n replies, 'no'.", NULL, NULL, TO_ROOM);
> else if (rank == 2 || rank == 6 || rank == 10)
> act("$n replies, 'it's not'.", NULL, NULL, TO_ROOM);
> else if (rank == 3 || rank == 7 || rank == 11)
> act("$n replies, 'no it's not'.", NULL, NULL, TO_ROOM);
> else if (rank == 4 || rank == 8 || rank == 12)
> act("$n replies, 'sorry, it's not a heart'.", NULL, NULL, TO_ROOM);
> }
> return;
> }
>
> if (!str_cmp(arg1, "club")) {
>
> if (suit == CLUB) {
> if (rank == 1 || rank == 5 || rank == 9 || rank == 13)
> act("$n replies, 'yes!'.", NULL, NULL, TO_ROOM);
> else if (rank == 2 || rank == 6 || rank == 10)
> act("$n replies, 'it is!'.", NULL, NULL, TO_ROOM);
> else if (rank == 3 || rank == 7 || rank == 11)
> act("$n replies, 'yes it is!'.", NULL, NULL, TO_ROOM);
> else if (rank == 4 || rank == 8 || rank == 12)
> act("$n replies, 'it is a club!'.", NULL, NULL, TO_ROOM);
> }
> else {
> if (rank == 1 || rank == 5 || rank == 9 || rank == 13)
> act("$n replies, 'no'.", NULL, NULL, TO_ROOM);
> else if (rank == 2 || rank == 6 || rank == 10)
> act("$n replies, 'it's not'.", NULL, NULL, TO_ROOM);
> else if (rank == 3 || rank == 7 || rank == 11)
> act("$n replies, 'no it's not'.", NULL, NULL, TO_ROOM);
> else if (rank == 4 || rank == 8 || rank == 12)
> act("$n replies, 'sorry, it's not a club'.", NULL, NULL, TO_ROOM);
> }
> return;
> }
>
> if (!str_cmp(arg1, "diamond")) {
>
> if (suit == DIAMOND) {
> if (rank == 1 || rank == 5 || rank == 9 || rank == 13)
> act("$n replies, 'yes!'.", NULL, NULL, TO_ROOM);
> else if (rank == 2 || rank == 6 || rank == 10)
> act("$n replies, 'it is!'.", NULL, NULL, TO_ROOM);
> else if (rank == 3 || rank == 7 || rank == 11)
> act("$n replies, 'yes it is!'.", NULL, NULL, TO_ROOM);
> else if (rank == 4 || rank == 8 || rank == 12)
> act("$n replies, 'it is a diamond!'.", NULL, NULL, TO_ROOM);
> }
> else {
> if (rank == 1 || rank == 5 || rank == 9 || rank == 13)
> act("$n replies, 'no'.", NULL, NULL, TO_ROOM);
> else if (rank == 2 || rank == 6 || rank == 10)
> act("$n replies, 'it's not'.", NULL, NULL, TO_ROOM);
> else if (rank == 3 || rank == 7 || rank == 11)
> act("$n replies, 'no it's not'.", NULL, NULL, TO_ROOM);
> else if (rank == 4 || rank == 8 || rank == 12)
> act("$n replies, 'sorry, it's not a diamond'.", NULL, NULL, TO_ROOM);
> }
> return;
> }
>
> if (!arg1.empty() && !is_number(arg1) && !arg2.empty() && is_number(arg2)
> &&(
> !arg3.empty() && is_number(arg3) || 4 == std::atoi(arg2.c_str())
> )
> )
> {
> int guess_rank = std::atoi(arg2.c_str());
> int guess_suit = std::atoi(arg3.c_str());
> if (guess_rank == rank && guess_suit == suit) {
> act("$n exclaims, 'Right!'.", NULL, NULL, TO_ROOM);
> if (obj->value[2] == 0) { // if no one looked at the card
> Character *winner = get_char_room(arg1);
> obj->obj_from_char();
> obj->obj_to_char(winner);
> MOBtrigger = false;
> act("$n gives $p to $N.", obj, winner, TO_NOTVICT);
> act("$n gives you $p.", obj, winner, TO_VICT);
> act("You give $p to $N.", obj, winner, TO_CHAR);
> mprog_give_trigger(winner, this, obj);
> }
> }
> else act("$n frowns and shakes $l head.", NULL, NULL, TO_ROOM);
> return;
> }


card_color_or_suit_guess.prg
>give_prog all~
if objtype($o) == 13
mpcardguess
endif
~
>speech_prog p black~
mpcardguess black
~
>speech_prog p red~
mpcardguess red
~
>speech_prog p spade~
mpcardguess spade
~
>speech_prog p heart~
mpcardguess heart
~
>speech_prog p club~
mpcardguess club
~
>speech_prog p diamond~
mpcardguess diamond
~
|


card_named_is_black.prg
>speech_prog p Ace of Spades~
mpcardguess $n 1 1
~
>speech_prog p Two of Spades~
mpcardguess $n 2 1
~
>speech_prog p Three of Spades~
mpcardguess $n 3 1
~
>speech_prog p Four of Spades~
mpcardguess $n 4 1
~
>speech_prog p Five of Spades~
mpcardguess $n 5 1
~
>speech_prog p Six of Spades~
mpcardguess $n 6 1
~
>speech_prog p Seven of Spades~
mpcardguess $n 7 1
~
>speech_prog p Eight of Spades~
mpcardguess $n 8 1
~
>speech_prog p Nine of Spades~
mpcardguess $n 9 1
~
>speech_prog p Ten of Spades~
mpcardguess $n 10 1
~
>speech_prog p Jack of Spades~
mpcardguess $n 11 1
~
>speech_prog p Queen of Spades~
mpcardguess $n 12 1
~
>speech_prog p King of Spades~
mpcardguess $n 13 1
~
>speech_prog p Ace of Clubs~
mpcardguess $n 1 3
~
>speech_prog p Two of Clubs~
mpcardguess $n 2 3
~
>speech_prog p Three of Clubs~
mpcardguess $n 3 3
~
>speech_prog p Four of Clubs~
mpcardguess $n 4 3
~
>speech_prog p Five of Clubs~
mpcardguess $n 5 3
~
>speech_prog p Six of Clubs~
mpcardguess $n 6 3
~
>speech_prog p Seven of Clubs~
mpcardguess $n 7 3
~
>speech_prog p Eight of Clubs~
mpcardguess $n 8 3
~
>speech_prog p Nine of Clubs~
mpcardguess $n 9 3
~
>speech_prog p Ten of Clubs~
mpcardguess $n 10 3
~
>speech_prog p Jack of Clubs~
mpcardguess $n 11 3
~
>speech_prog p Queen of Clubs~
mpcardguess $n 12 3
~
>speech_prog p King of Clubs~
mpcardguess $n 13 3
~
|


card_named_is_red.prg
>speech_prog p Ace of Hearts~
mpcardguess $n 1 2
~
>speech_prog p Two of Hearts~
mpcardguess $n 2 2
~
>speech_prog p Three of Hearts~
mpcardguess $n 3 2
~
>speech_prog p Four of Hearts~
mpcardguess $n 4 2
~
>speech_prog p Five of Hearts~
mpcardguess $n 5 2
~
>speech_prog p Six of Hearts~
mpcardguess $n 6 2
~
>speech_prog p Seven of Hearts~
mpcardguess $n 7 2
~
>speech_prog p Eight of Hearts~
mpcardguess $n 8 2
~
>speech_prog p Nine of Hearts~
mpcardguess $n 9 2
~
>speech_prog p Ten of Hearts~
mpcardguess $n 10 2
~
>speech_prog p Jack of Hearts~
mpcardguess $n 11 2
~
>speech_prog p Queen of Hearts~
mpcardguess $n 12 2
~
>speech_prog p King of Hearts~
mpcardguess $n 13 2
~
>speech_prog p Ace of Diamonds~
mpcardguess $n 1 4
~
>speech_prog p Two of Diamonds~
mpcardguess $n 2 4
~
>speech_prog p Three of Diamonds~
mpcardguess $n 3 4
~
>speech_prog p Four of Diamonds~
mpcardguess $n 4 4
~
>speech_prog p Five of Diamonds~
mpcardguess $n 5 4
~
>speech_prog p Six of Diamonds~
mpcardguess $n 6 4
~
>speech_prog p Seven of Diamonds~
mpcardguess $n 7 4
~
>speech_prog p Eight of Diamonds~
mpcardguess $n 8 4
~
>speech_prog p Nine of Diamonds~
mpcardguess $n 9 4
~
>speech_prog p Ten of Diamonds~
mpcardguess $n 10 4
~
>speech_prog p Jack of Diamonds~
mpcardguess $n 11 4
~
>speech_prog p Queen of Diamonds~
mpcardguess $n 12 4
~
>speech_prog p King of Diamonds~
mpcardguess $n 13 4
~
|


Enjoy! A next step would be being able to turn in card hands or a full deck for items, abilities, etc.
23 Feb, 2022, wifidi wrote in the 2nd comment:
Votes: 0
Whoops – the third kind of reply to guessing the color or suit should be for ranks 9 to 12. 13 is all alone on the fourth row in this game, so it can be shortcutted to make the guesser seem like an even more amazing genius/psychic.
0.0/2