MagicDuel Wiki
Advertisement

mds_is_ctc

mds_is_ctc - Gets information about the creature corresponding to the transfer code.

Description

array mds_is_ctc(string $ctc)

Gets information about the creature corresponding to the transfer code.

Parameters

ctc
The string containing a creature transfer code to evaluate.
Never use the full CTC string or it will be treated as invalid and return false.

Return Values

Returns False if invalid CTC is supplied, otherwise it returns an array with item information.
The return array is in this form:

array(){
["id"] => creature ID
["uid"] => owner ID
["playername"] => owner Playername
["cid"] => creature type
["tokens"] => tokens held by creature
["dateBorn"] => timestamp when creature was created
["transfercount"] => number of transfers
["tradevalue"] => trade value
["customName"] => custom name of the creature, if any
["vitality"] => creature's maximum vitality
["level"] => creature's level
["experience"] => creature's experience
["battlesWon"] => number of battles won by creatre
["age"] => creature's age in days
}

Examples

example #1

@vc= mds_is_ctc(@input['ctc']);
if (@vc) {
	echo "Creature Owner:".@vc["playername"]."<br>";
	echo "Creature ID:".@vc["id"]."<br>";
	echo "Creature birthdate:".date("F j, Y, g:i a",@vc["dateBorn"])."<br>";
	echo "Creature level:".@vc["level"]."<br>";
	echo "Creature age:".@vc["age"]."<br>";
}

 

example #2

 HTML
<form method="post" action="">
Pete the Bull stands guard, send the CTC's* of the creatures to defeat him<br />
<input name="ctc0" type="text" /><br />
<input name="ctc1" type="text" /><br />
<input name="ctc2" type="text" /><br />
<input name="ctc3" type="text" /><br />
<br />
<input name="submit" type="submit" value="Submit"/><br />
<br />
<font size="1px">*Copy from "CTC" to "MDC", not the entire code</font>
</form>
 MDScript
if(isset(@input['submit'])) { //check that button was clicked
	//load the "ctc"'s into an array
	@vc[0]= mds_is_ctc(@input['ctc0']);
	@vc[1]= mds_is_ctc(@input['ctc1']);
	@vc[2]= mds_is_ctc(@input['ctc2']);
	@vc[3]= mds_is_ctc(@input['ctc3']);
	
	//check whether ctc's are valid
	if(@vc[0] && (@vc[1]) && (@vc[2]) && (@vc[3])){
		@vt = true;
		//test for repeats
		//set the counters of each creature type in associative array
		for(@vi = 0; @vi < 3; @vi++){
			for(@vj = @vi + 1; @vj < 4; @vj++){
				if(@vc[@vi]['id'] == @vc[@vj]['id']){
					@vt = false;
					break;
				}
			}
			if(isset(@vd["" . @vc[@vi]['cid']]))
				++@vd["" . @vc[@vi]['cid']];
			else 
				@vd["" . @vc[@vi]['cid']] = 1;
		}
		if(isset(@vd["" . @vc[3]['cid']]))
			++@vd["" . @vc[3]['cid']];
		else
			@vd["" . @vc[3]['cid']] = 1;
		//check there are no repeats
		if(@vt){
			//create an array of the creature types
			@va = array(@vc[0]['cid'], @vc[1]['cid'], @vc[2]['cid'], @vc[3]['cid']);
			//check if required creatures types are in the array
			if((@vd['12'] == 2) && (@vd['2'] == 1) && (@vd['5'] == 1)){
				echo "you have defeated pete the bull!";
			}else{
				echo "pete laughs at your feeble attacks";
			}
		}else{
			echo "pete looks at " . uv('name') . " with doubt";
		}
	}else	{
		echo "inva"."lid ctc(s) supplied";
	}
}else{
	//echo the html, it is not shown by default
	echo @content[0];
}

See Also

  • mds_is_itc()- Gets information about the item corresponding to the transfer code.


Advertisement