[Turn off line numbering]1: arg left, right; 2: var x, str, out, cards, last; 3: 4: left = .break_cards(left); 5: right = .break_cards(right); 6: if (left[2].length() != right[2].length()) 7: throw(~invrel, "Left side cards differ from the right side."); 8: str = ""; 9: for x in (left[1]) { 10: if (type(x) == 'string) 11: str += x; 12: else if (str && str[strlen(str)] == "*") 13: str += " *"; 14: else 15: str += "*"; 16: } 17: 18: // and now for some sanity... 19: cards = #[]; 20: for x in (left[2]) { 21: if (x != last + 1) 22: throw(~invcard, "Left side cards are not in sequence (%" + x + " before %" + (x - 1) + ")."); 23: last = x; 24: cards = dict_add(cards, x, 1); 25: } 26: 27: // move to the right side 28: out = [str, @left]; 29: str = ""; 30: for x in (right[1]) { 31: if (type(x) == 'string) 32: str += x; 33: else 34: str += "*"; 35: } 36: 37: // final sanity check... 38: for x in (right[2]) { 39: if (!dict_contains(cards, x)) 40: throw(~invcard, "Card %" + x + " does not exist on the left side!"); 41: } 42: 43: // good... 44: return [out, [str, @right]];
// Created 27-Mar-1995 as a part of ColdCore, see: @help Credit