Add some more changes
This commit is contained in:
parent
97f0e4a475
commit
b464adae4a
5 changed files with 456 additions and 97 deletions
|
@ -5,8 +5,27 @@ integer updater_channel = 15418070;
|
|||
integer card_channel = -32988199;
|
||||
integer hud_channel = -328478727;
|
||||
|
||||
integer g_iSelectNum;
|
||||
list g_lPoints;
|
||||
integer g_iStarted;
|
||||
integer g_iExpectDeckLoad;
|
||||
|
||||
list StrideOfList(list src, integer stride, integer start, integer end)
|
||||
{
|
||||
list l = [];
|
||||
integer ll = llGetListLength(src);
|
||||
if(start < 0)start += ll;
|
||||
if(end < 0)end += ll;
|
||||
if(end < start) return llList2List(src, start, start);
|
||||
while(start <= end)
|
||||
{
|
||||
l += llList2List(src, start, start);
|
||||
start += stride;
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
GiveUserPoint(key kUser){
|
||||
// point list - user, num of points
|
||||
integer index = llListFindList(g_lPoints,[kUser]);
|
||||
|
@ -20,6 +39,20 @@ GiveUserPoint(key kUser){
|
|||
UpScores();
|
||||
}
|
||||
|
||||
SetupDeck(){
|
||||
string deckStr;
|
||||
list decks;
|
||||
integer i=0;
|
||||
integer end = llGetListLength(g_lSelectedDecks);
|
||||
for(i=0;i<end;i+=2){
|
||||
if((integer)(llList2String(g_lSelectedDecks,i+1)))decks+=llList2String(g_lSelectedDecks,i);
|
||||
}
|
||||
deckStr=llDumpList2String(decks, ",");
|
||||
llSay(0, "Shuffling cards for decks: "+deckStr);
|
||||
Send("/Modify_Card.php?TYPE_OVERRIDE=MAKE_DECK&TABLE_ID="+(string)g_kID+"&DECKS="+deckStr, "POST");
|
||||
}
|
||||
|
||||
|
||||
UpScores(){
|
||||
|
||||
integer i=0;
|
||||
|
@ -44,8 +77,9 @@ UpScores(){
|
|||
|
||||
list g_lJudgePile;
|
||||
integer g_iTotalJudgeUsers;
|
||||
list g_lSelectedDecks = ["OFFICIAL",1];
|
||||
|
||||
string g_sVersion = "1.0.0.0000";
|
||||
string g_sVersion = "1.0.0.0002";
|
||||
key g_kToken;
|
||||
integer DEBUG = FALSE;
|
||||
float offset;
|
||||
|
@ -67,7 +101,7 @@ key g_kCurrentReq = NULL_KEY;
|
|||
DoNextRequest(){
|
||||
if(llGetListLength(g_lReqs)==0)return;
|
||||
list lTmp = llParseString2List(llList2String(g_lReqs,0),["?"],[]);
|
||||
if(DEBUG)llSay(0, "SENDING REQUEST: "+URL+llList2String(g_lReqs,0));
|
||||
//if(DEBUG)llSay(0, "SENDING REQUEST: "+URL+llList2String(g_lReqs,0));
|
||||
|
||||
string append = "";
|
||||
if(llList2String(g_lReqs,1) == "GET")append = "?"+llDumpList2String(llList2List(lTmp,1,-1),"?");
|
||||
|
@ -172,10 +206,14 @@ integer g_iBlockRez = 0;
|
|||
key g_kCurrentBlackCard;
|
||||
list g_lPendingCards;
|
||||
|
||||
AddLogEntry(string from, string to, integer cost, string notes){
|
||||
Send("/Logger.php?LOG_TYPE=ADD&ORIGIN="+llEscapeURL(from)+"&DESTINATION="+llEscapeURL(to)+"&PRICE="+(string)cost+"&NOTES="+llStringToBase64(notes), "POST");
|
||||
}
|
||||
default
|
||||
{
|
||||
state_entry()
|
||||
{
|
||||
llMessageLinked(LINK_SET,-1,"","");
|
||||
llSitTarget(ZERO_VECTOR,ZERO_ROTATION);
|
||||
Chairs=[];
|
||||
UpScores();
|
||||
|
@ -199,11 +237,15 @@ default
|
|||
llWhisper(0, "Stand by...");
|
||||
g_kID = (key)llGetObjectDesc();
|
||||
if(g_kID == "new_lsk"){
|
||||
g_kID = llGenerateKey();
|
||||
llListen(99, "", llGetOwner(), "");
|
||||
llDialog(llGetOwner(), "Is this a new table or a upgraded one?", ["New", "Upgrade"], 99);
|
||||
|
||||
/*g_kID = llGenerateKey();
|
||||
llSetObjectDesc((string)g_kID);
|
||||
llSay(0, "First Rez! Thank you for your purchase of an LS Bionics product!\n \n[Generating License Key]");
|
||||
llSetObjectName("Cards Against Humanity [LS]");
|
||||
Send("/Put_Product_Data.php?PRODUCT=CAH_TABLE&KEYID="+(string)g_kID+"&NICKNAME=License&DATA=1","POST");
|
||||
return;*/
|
||||
return;
|
||||
}
|
||||
llWhisper(card_channel, llList2Json(JSON_OBJECT, ["type", "die", "table", g_kID]));
|
||||
|
@ -211,7 +253,7 @@ default
|
|||
Evict(Players);
|
||||
|
||||
|
||||
state license_check;
|
||||
llMessageLinked(LINK_SET, 0, "", g_kID);
|
||||
}
|
||||
|
||||
http_response(key r,integer s,list m,string b){
|
||||
|
@ -225,61 +267,55 @@ default
|
|||
}
|
||||
}
|
||||
|
||||
listen(integer c,string n,key i,string m){
|
||||
if(c==99){
|
||||
if(m == "New"){
|
||||
g_kID = llGenerateKey();
|
||||
llSetObjectDesc((string)g_kID);
|
||||
llSay(0, "First Rez! Thank you for your purchase of an LS Bionics product!\n \n[Generating License Key]");
|
||||
llSetObjectName("Cards Against Humanity [LS]");
|
||||
Send("/Put_Product_Data.php?PRODUCT=CAH_TABLE&KEYID="+(string)g_kID+"&NICKNAME=License&DATA=1", "POST");
|
||||
llResetScript();
|
||||
} else if(m == "Upgrade"){
|
||||
llListen(ingredient_channel+1, "", "", "");
|
||||
llSay(ingredient_channel, "scan");
|
||||
llWhisper(0, "Scanning for settings");
|
||||
return;
|
||||
}
|
||||
} else if(c==ingredient_channel+1){
|
||||
if(m == "rezzed CAH_TABLE" || m == "CAH_TABLE"){
|
||||
llSetObjectDesc(llList2String(llGetObjectDetails(i,[OBJECT_DESC]),0));
|
||||
llWhisper(0, "Loaded Settings");
|
||||
llRegionSayTo(i, ingredient_channel, (string)i);
|
||||
llResetScript();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
on_rez(integer t){
|
||||
llResetScript();
|
||||
}
|
||||
|
||||
link_message(integer s,integer n,string m,key i){
|
||||
if(n==1){
|
||||
g_lSelectedDecks = llParseString2List(m,["~"],[]);
|
||||
state active;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
state license_check
|
||||
{
|
||||
state_entry(){
|
||||
//llSay(0, "Checking for a game license... Please hold on awhile while I process your request");
|
||||
Send("/Get_Product_Data.php?PRODUCT=CAH_TABLE&KEYID="+(string)g_kID+"&NICKNAME=License", "GET");
|
||||
}
|
||||
|
||||
http_response(key r,integer s,list m, string b){
|
||||
if(r == g_kCurrentReq){
|
||||
g_kCurrentReq = NULL_KEY;
|
||||
g_lReqs = llDeleteSubList(g_lReqs,0,1);
|
||||
|
||||
list lTmp = llParseString2List(b,[";;",";"],[]);
|
||||
string Script = llList2String(lTmp,0);
|
||||
if(Script == "Get_Product_Data")
|
||||
{
|
||||
string Variable = llList2String(lTmp,1);
|
||||
if(llList2String(lTmp,2) == "1"){
|
||||
//llSay(0, "License is now activated!");
|
||||
state active;
|
||||
} else {
|
||||
llSay(0, "ERROR: No valid license key has been found. Try again later, or contact LS Bionics support\n\n[Error code: "+llList2String(lTmp,2)+"]");
|
||||
}
|
||||
}
|
||||
|
||||
Sends();
|
||||
}
|
||||
}
|
||||
|
||||
on_rez(integer t){
|
||||
llResetScript();
|
||||
}
|
||||
|
||||
changed(integer t){
|
||||
if(t&CHANGED_REGION_START){
|
||||
llResetScript();
|
||||
}
|
||||
}
|
||||
}
|
||||
state active
|
||||
{
|
||||
state_entry(){
|
||||
llSay(0, "Game Table now ready");
|
||||
llSay(0, "Shuffling cards...");
|
||||
Send("/Modify_Card.php?TYPE_OVERRIDE=MAKE_DECK&TABLE_ID="+(string)g_kID, "POST");
|
||||
llSay(0, "Game Table now ready ("+(string)llGetFreeMemory()+"b)");
|
||||
SetupDeck();
|
||||
g_iBlockRez=0;
|
||||
g_lPending=[];
|
||||
|
||||
llSay(card_channel, llList2Json(JSON_OBJECT, ["type", "die", "table", g_kID]));
|
||||
llListen(hud_channel, "", "", "");
|
||||
llListen(ingredient_channel+1, "", "", "");
|
||||
llListen(updater_channel, "", "", "");
|
||||
llListen(card_channel, "", "", "");/*
|
||||
integer chan = llRound(llFrand(548378));
|
||||
g_lPendingCards += [chan, "null|black"];
|
||||
|
@ -293,14 +329,14 @@ state active
|
|||
g_lReqs = llDeleteSubList(g_lReqs,0,1);
|
||||
|
||||
list lTmp = llParseString2List(b,[";;",";"],[]);
|
||||
if(DEBUG)llSay(0, "HTTP REPLY: "+b);
|
||||
//if(DEBUG)llSay(0, "HTTP REPLY: "+b);
|
||||
string Script = llList2String(lTmp,0);
|
||||
if(Script == "Modify_Deck"){
|
||||
llSay(0, "Deck generated!");
|
||||
llSay(0, "Deck generated with total cards: "+llList2String(lTmp,3));
|
||||
} else if(Script == "Get_Card"){
|
||||
key Sender = (key)llList2String(lTmp,1);
|
||||
list Params = llJson2List(llBase64ToString(llList2String(lTmp,2)));
|
||||
if(DEBUG)llSay(0, "PARAMETER LIST: "+llList2CSV(Params));
|
||||
//if(DEBUG)llSay(0, "PARAMETER LIST: "+llList2CSV(Params));
|
||||
|
||||
//llParseString2List(llBase64ToString(llList2String(lTmp,2)), ["|"],[]);
|
||||
integer i=0;
|
||||
|
@ -330,6 +366,7 @@ state active
|
|||
llSay(0, "Card Czar is: secondlife:///app/agent/"+(string)czar+"/about");
|
||||
|
||||
llRegionSay(hud_channel, llList2Json(JSON_OBJECT, ["type", "select", "czar", czar, "sel_count", num_req, "table", g_kID]));
|
||||
g_iSelectNum = num_req;
|
||||
}
|
||||
llRegionSayTo(Sender, card_channel, llList2Json(JSON_OBJECT, ["type", "set", "card", llList2Json(JSON_OBJECT, ["text", card_text, "color", color, "num", num_req, "czar", llList2String(Players,g_iCzar), "user", llList2String(lTmp,3)])]));
|
||||
}
|
||||
|
@ -341,7 +378,7 @@ state active
|
|||
integer num = llList2Integer(lTmp,4);
|
||||
string user = llList2String(lTmp,5);
|
||||
|
||||
if(DEBUG)llSay(0, "SEARCH RESULT: "+Text);
|
||||
//if(DEBUG)llSay(0, "SEARCH RESULT: "+Text);
|
||||
} else if(Script == "No More Cards"){
|
||||
|
||||
llSay(0, "Game over! No more black cards exist in the deck... Checking for winner...");
|
||||
|
@ -360,6 +397,23 @@ state active
|
|||
|
||||
llSay(0, "WINNER IS: secondlife:///app/agent/"+(string)kLastHigh+"/about with "+(string)iLastHigh+" points total!!");
|
||||
llResetScript();
|
||||
} else if(Script == "Modify_Product"){
|
||||
if(llList2String(lTmp,1)=="Cards Against Humanity [LS]"){
|
||||
if(g_sVersion != llList2String(lTmp,2)){
|
||||
AddLogEntry(llKey2Name(llGetOwner()), "SYSTEM", 0, "Request delivery of product update: "+llGetObjectName());
|
||||
llRegionSayTo(g_kToken,updater_channel,(string)g_kToken);
|
||||
Send("/Get_Server_URL.php?NAME=Products","GET");
|
||||
llWhisper(0, "Requesting product update delivery");
|
||||
} else {
|
||||
llRegionSayTo(g_kToken, updater_channel, "no_update");
|
||||
llWhisper(0, "I am up to date");
|
||||
}
|
||||
}
|
||||
} else if(Script == "Get_Server_URL"){
|
||||
if(llList2String(lTmp,1)=="Products"){
|
||||
llHTTPRequest(llList2String(lTmp,2), [HTTP_METHOD,"POST", HTTP_MIMETYPE, "application/x-www-form-urlencoded"], llList2Json(JSON_OBJECT, ["creator", llGetInventoryCreator(llGetScriptName()), "owner", llGetOwner(), "product", "Cards Against Humanity [LS]"]));
|
||||
state ingred;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -368,9 +422,7 @@ state active
|
|||
}
|
||||
|
||||
listen(integer c,string n,key i, string m){
|
||||
if(DEBUG){
|
||||
llSay(0, "LISTEN: "+llDumpList2String([c,n,i,m], " - "));
|
||||
}
|
||||
//if(DEBUG) llSay(0, "LISTEN: "+llDumpList2String([c,n,i,m], " - "));
|
||||
if(c==hud_channel){
|
||||
if(llJsonGetValue(m,["type"])=="card_request"){
|
||||
integer card_count = (integer)llJsonGetValue(m,["count"]);
|
||||
|
@ -380,7 +432,7 @@ state active
|
|||
if(index==-1)return;
|
||||
else {
|
||||
// Boot the HUD
|
||||
if(DEBUG)llSay(0, "Sending HUD Activation signal");
|
||||
//if(DEBUG)llSay(0, "Sending HUD Activation signal");
|
||||
index--;
|
||||
|
||||
|
||||
|
@ -395,6 +447,7 @@ state active
|
|||
if(g_iTotalJudgeUsers == llGetListLength(Players)-1){
|
||||
llSay(hud_channel, llList2Json(JSON_OBJECT, ["type", "judging", "table", g_kID]));
|
||||
llSay(0, "Card Czar: Pick the card you want!");
|
||||
llDialog(llList2Key(Players,g_iCzar), "[LS Bionics]\nCards Against Humanity\n\nINSTRUCTIONS: Click the card you want to pick twice, once to select, a second time to confirm. If you have to select more than 1 card, you must select the first card first, then the second card. Once the required number of cards have been selected, the others will automatically de-rez and a new black card will be generated.\n\nPlay: "+(string)g_iSelectNum+" cards", ["-exit-"], -3999);
|
||||
// Initiate the rezzing procedure
|
||||
integer x =0;
|
||||
integer e = llGetListLength(g_lJudgePile);
|
||||
|
@ -429,7 +482,7 @@ state active
|
|||
offset = 0.0;
|
||||
}
|
||||
llRegionSayTo(i, card_channel, llList2Json(JSON_OBJECT, ["type", "position", "pos", llGetPos()+<0,offset,0.75>]));
|
||||
if(DEBUG)llSay(0, "Alive request on the Cards Channel: "+m);
|
||||
//if(DEBUG)llSay(0, "Alive request on the Cards Channel: "+m);
|
||||
|
||||
string color = "1";
|
||||
offset += 0.25;
|
||||
|
@ -447,24 +500,33 @@ state active
|
|||
} else if(llJsonGetValue(m,["type"]) == "final"){
|
||||
key kUser = (key)llJsonGetValue(m,["user"]);
|
||||
GiveUserPoint(kUser);
|
||||
llWhisper(0, "secondlife:///app/agent/"+(string)kUser+"/about won the round and gets the point.");
|
||||
g_iSelectNum--;
|
||||
|
||||
llSay(card_channel, llList2Json(JSON_OBJECT, ["type", "die", "table", g_kID]));
|
||||
// Start next round!
|
||||
// Load the next black card to trigger selection mode
|
||||
integer boot = llRound(llFrand(5483758));
|
||||
g_lPendingCards += [boot, "null|black"];
|
||||
if(g_iSelectNum == 0){
|
||||
|
||||
integer x =0;
|
||||
integer ends = llGetListLength(g_lJudgePile);
|
||||
g_iTotalJudgeUsers = 0;
|
||||
for(x=0;x<ends;x++){
|
||||
string card = llList2String(g_lJudgePile,x);
|
||||
Send("/Modify_Card.php?TYPE_OVERRIDE=INSERT&TABLE_ID="+(string)g_kID+"&CARD_TEXT="+llStringToBase64(llJsonGetValue(card,["text"])), "POST");
|
||||
llWhisper(0, "secondlife:///app/agent/"+(string)kUser+"/about receives a point");
|
||||
|
||||
llSay(card_channel, llList2Json(JSON_OBJECT, ["type", "die", "table", g_kID]));
|
||||
// Start next round!
|
||||
// Load the next black card to trigger selection mode
|
||||
integer boot = llRound(llFrand(5483758));
|
||||
g_lPendingCards += [boot, "null|black"];
|
||||
|
||||
integer x =0;
|
||||
integer ends = llGetListLength(g_lJudgePile);
|
||||
g_iTotalJudgeUsers = 0;
|
||||
for(x=0;x<ends;x++){
|
||||
string card = llList2String(g_lJudgePile,x);
|
||||
Send("/Modify_Card.php?TYPE_OVERRIDE=INSERT&TABLE_ID="+(string)g_kID+"&CARD_TEXT="+llEscapeURL(llStringToBase64(llJsonGetValue(card,["text"]))), "POST");
|
||||
}
|
||||
|
||||
g_lJudgePile=[];
|
||||
llRezObject("Playing Card [LS]", llGetPos(), ZERO_VECTOR,ZERO_ROTATION,boot);
|
||||
} else {
|
||||
llRegionSayTo(i,card_channel, llList2Json(JSON_OBJECT, ["type", "die", "table", g_kID]));
|
||||
llWhisper(0, "secondlife:///app/agent/"+(string)kUser+"/about was one of the selected cards and receives a point");
|
||||
llWhisper(0, "Card Czar: "+(string)g_iSelectNum+" more cards are required");
|
||||
}
|
||||
|
||||
g_lJudgePile=[];
|
||||
llRezObject("Playing Card [LS]", llGetPos(), ZERO_VECTOR,ZERO_ROTATION,boot);
|
||||
}
|
||||
} else if(llListFindList(g_lListener,[c])!=-1){
|
||||
integer index = llListFindList(g_lListener,[c]);
|
||||
|
@ -478,7 +540,28 @@ state active
|
|||
llListenRemove(llList2Integer(g_lListener,index+2));
|
||||
g_lListener=llDeleteSubList(g_lListener,index,index+2);
|
||||
|
||||
} else if(c==ingredient_channel+1){
|
||||
if(m == "rezzed Deck" || m == "Deck"){
|
||||
if(g_iExpectDeckLoad){
|
||||
g_iExpectDeckLoad = 0;
|
||||
string Deck = llList2String(llGetObjectDetails(i,[OBJECT_DESC]),0);
|
||||
llWhisper(0, "Activating deck...");
|
||||
llMessageLinked(LINK_SET,5,Deck,"");
|
||||
llRegionSayTo(i, ingredient_channel, (string)i);
|
||||
|
||||
llWhisper(0, "Deck activated!");
|
||||
}
|
||||
}
|
||||
} else if(c == updater_channel){
|
||||
if(m == "scan"){
|
||||
llRegionSayTo(i,c,"reply|CAH");
|
||||
} else if(m == "check"){
|
||||
llWhisper(0, "Checking for update..");
|
||||
g_kToken=i;
|
||||
Send("/Modify_Product.php?NAME="+llEscapeURL("Cards Against Humanity [LS]"), "GET");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
changed(integer t){
|
||||
|
@ -495,6 +578,11 @@ state active
|
|||
|
||||
timer(){
|
||||
Sends();
|
||||
|
||||
if(llGetTime()>=15.0 && g_iExpectDeckLoad){
|
||||
g_iExpectDeckLoad=0;
|
||||
llWhisper(0, "No nearby deck found");
|
||||
}
|
||||
}
|
||||
|
||||
touch_start(integer t){
|
||||
|
@ -502,6 +590,7 @@ state active
|
|||
if(name == "START"){
|
||||
if(g_iStarted)return;
|
||||
g_iStarted=TRUE;
|
||||
llMessageLinked(LINK_SET,11,"","");
|
||||
if(!(llGetListLength(Players) > 1)){
|
||||
llSay(0, "Must have more than 1 player to start!");
|
||||
return;
|
||||
|
@ -526,4 +615,46 @@ state active
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
link_message(integer s,integer n,string m,key i){
|
||||
if(n==-2){
|
||||
llResetScript();
|
||||
} else if(n == 10){
|
||||
g_iExpectDeckLoad=1;
|
||||
llResetTime();
|
||||
llSay(ingredient_channel, "scan");
|
||||
llWhisper(0, "Scanning for a deck of cards");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
state ingred
|
||||
{
|
||||
state_entry(){
|
||||
llSetTimerEvent(0);
|
||||
llListen(ingredient_channel, "", "", "");
|
||||
llSetText("Cards Against Humanity Settings\n----\nQuantity: 1", <0,1,0>,1);
|
||||
}
|
||||
on_rez(integer t){
|
||||
llListen(ingredient_channel, "", "", "");
|
||||
}
|
||||
|
||||
changed(integer c){
|
||||
if(c&CHANGED_REGION_START){
|
||||
llListen(ingredient_channel, "", "", "");
|
||||
}
|
||||
}
|
||||
|
||||
listen(integer c,string n,key i,string m){
|
||||
if(m == "scan"){
|
||||
llRegionSayTo(i,ingredient_channel+1, "CAH_TABLE");
|
||||
}else if(m == (string)llGetKey()){
|
||||
llDie();
|
||||
}
|
||||
}
|
||||
|
||||
touch_start(integer t){
|
||||
llSay(0, "Cards Against Humanity Settings; Quantity: 1");
|
||||
llSay(ingredient_channel+1, "CAH_TABLE");
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue