var point=new Array();
var s1, s2;
function sample(){
$("#p1").click(function () {
var urlx = "play.php?x=" + s1 + "&y=" + s2;
$("#memo").load(urlx);
f();
});
$("#p2").click(function () {
var urlx = "play.php?x=" + s2 + "&y=" + s1;
$("#memo").load(urlx);
f();
});
f();
}
function f(){
data = new XMLHttpRequest();
data.open("GET", "data.txt", false);
data.send(null);
var str=data.responseText;
point = str.split(",");
s1 = 0;
for (s = 1; s < 11;s++ ){
if(point[s]==2)s1=s;
}
s2 = 0;
for (s = 1; s < s1;s++ ){
if(point[s]==2)s2=s;
}
$("#memo").html(s1+","+s2);
}
<?php
$x=$_GET["x"];
$y=$_GET["y"];
$memo="";
$fp = fopen("data.txt", "r");
while ($line = fgets($fp)) {
$memo=$memo.$line;
}
fclose($fp);
$px=explode(",",$memo);
$h=0;
if($px[$x]==2)$h=$h+1;
if($px[$y]==2)$h=$h+1;
if($h==2){
$px[$x]=1;
$px[$y]=3;
$sx=0;
for($s=1;$s<11;$s++){
if($px[$s]==1)$sx=$sx+1;
if($px[$s]==1)$a[$sx]=$s;
}
$n1=rand(1,$sx);
$n2=$a[$n1];
$px[$n2]=2;
$sx=0;
for($s=1;$s<11;$s++){
if($px[$s]==1)$sx=$sx+1;
if($px[$s]==1)$a[$sx]=$s;
}
$n1=rand(1,$sx);
$n2=$a[$n1];
$px[$n2]=2;
}
$memo="p";
for($s=1;$s<11;$s++){
$memo=$memo.",".$px[$s];
}
$fp2 = fopen("data.txt", "w");
fwrite($fp2,$memo);
fclose($fp2);
print($memo);
?>
最終更新:2015年10月12日 04:20