PeterMartyr Posted May 24 Share Posted May 24 string are primitives object persay, but int are primitive 100%, try again, answering this is waste of time this is a cut and paste Quote In the computer programming industry, primitive is a term used to describe a fundamental data type or code that can be used to build more complex software programs or interfaces. For instance, Java, a computer programming language, is made up of less complex data types such as Boolean, a primitive data type. Link to comment Share on other sites More sharing options...
dylbill Posted May 24 Share Posted May 24 Excuse me? That has nothing to do with the topic at hand, unless you're suggesting that different ints and strings can be set on the the same object because they're primitives, which is about the faultiest logic I've ever heard. All the cards created in the script are new objects with unique form ids. And, just to prove you wrong again, I modified the script. scriptname PlayingCard extends ObjectReference ;attach to a new misc object in the creation kit ObjectReference Property LinkedRef Auto then in another script: MiscObject Property Gold001 Auto Scroll Property CandlelightScroll Auto MiscObject Property playingCardMisc Auto ;PlayingCard script is attached Event OnInit() Utility.wait(1) PlayingCard cardA = PlayingCard.Create(0, 3, playingCardMisc) ;ace of spades PlayingCard cardB = PlayingCard.Create(12, 2, playingCardMisc) ;queen of hearts ObjectReference goldRef = Game.GetPlayer().PlaceAtMe(Gold001, 1) ObjectReference scrollRef = Game.GetPlayer().PlaceAtMe(CandlelightScroll, 1) cardA.LinkedRef = goldRef cardB.LinkedRef = scrollRef Debug.MessageBox(cardA.linkedRef.GetBaseObject() + " " + cardA.LinkedRef.GetDisplayName() + "\n" +\ cardB.linkedRef.GetBaseObject() + " " + cardB.LinkedRef.GetDisplayName()) EndEvent Here is the result. You're right about one thing, this conversation is pointless cause your ego won't let you admit you are wrong. This will be my last post on this topic. Have a nice day Link to comment Share on other sites More sharing options...
PeterMartyr Posted May 24 Share Posted May 24 struct PlayingCard { private: string suite; private: string value; public: // create a constructor PlayingCard(string: suite, string: value) { this.suite = suite; this.value= value } }; then like array you use the new keyword and slowly build a deck of Cards, until you have 52 playing cards, sorted into Four Suites, and a Deck, which copies what a real deck is.. and nothing is duplicated, we are not cheater, you shuffle the deck so it is random, then deal the cards to players, then boom shaka la your play poker... but we had to create 52 cards objects, 4 suite object or structs and one friggin deck of cards... that 57 objects, for a deck, btw we are using we are using composition not aggregation here, but I am leaving a lot out here Quote Aggregation implies a relationship where the child can exist independently of the parent. Example: Class (parent) and Student (child). Delete the Class and the Students still exist. Composition implies a relationship where the child cannot exist independent of the parent. Example: House (parent) and Room (child). Rooms don't exist separate to a House since we are using composition, if one card is lost, the entire deck is ruined and we need a new deck of cards, I hope you see it emulate playing in the real world Link to comment Share on other sites More sharing options...
PeterMartyr Posted May 24 Share Posted May 24 Damn I should have called that a "Card" any who once the deck is shuffle it is set in stone, the random come what the player do in the poker game, and the hand they are dealt.. we could also eliminate a suit and have a bi-dimensional array as a deck of cards [hearts][1][2][3][4] until [king] [spades] repeat above [clubs] dito [diamonds] & dito too with element it is this [0][0][1][2][3][4] until [12] [1][0][1][2][3][4] until [12] [2][0][1][2][3][4] until [12] [3][0][1][2][3][4] until [12] now I use in skyrim a Stack Data Structure that once the deck is shuffle goes into, so I can only deal of the top Link to comment Share on other sites More sharing options...
PeterMartyr Posted May 24 Share Posted May 24 Notice I am building a poker game that has no cheating very poorly but trust me no cheating is part of the brief edit1 once I create a Stack Structure for Skyrim let me find it and I will post it here Note this not for this card game and I freely post this and anyone can use it with no credit require, this a Form Stack Data Structure, great for a poker game to only deal off the top, LOL I think to remove peep, but as generic form stack I will leave it Yeah I need add that duplicates are rejected etc etc but it an examples of a stack, and length is not 51 either Spoiler ScriptName FDQStackArrayCW extends Form {A Stack Data Structure} Int Property Capacity = 128 AutoReadOnly Form[] theStack int top = 0 Event OnInit() If !theStack theStack = new Form[128] EndIf EndEvent Bool Function IsEmpty() Return top==0 EndFunction Bool Function IsFull() Return top==Capacity EndFunction Int Function GetSize() Return top EndFunction Function Push(form akForm) If !IsFull() theStack[top] = akForm top += 1 Else Debug.Trace(Self + " FormStack.Add() Overflow Error") EndIf EndFunction Form Function Pop() If !IsEmpty() top -= 1 Return theStack[top] EndIf Debug.Trace(Self + " FormStack.Pop() Underflow error") Return None EndFunction Form Function Peep() If !IsEmpty() Return theStack[top - 1] EndIf Return None EndFunction yeah I left out heaps, but create 52 Cards, shuffle the deck of cards so it random into a stack and deal off the top) we do not deal off the bottom, we are not cheaters, deal to the Players (yeah we need multiplayer) and play poker for gold coins in skyrim Link to comment Share on other sites More sharing options...
Sphered Posted May 24 Share Posted May 24 Yet you don't know what a mipmap or alpha channel is. Or how to convert a controller manager into separate controllers. Doubt you barely know 3dsmax. But sure, you have a niche that AI has likely replaced you in, so you are bitter and angry LMAO... Keep going dude, I used to be a prick in my day too.... then I realized I put my pants on just like everyone else does Link to comment Share on other sites More sharing options...
PeterMartyr Posted May 24 Share Posted May 24 @dylbill I sat down and wrote some code for clean deck of Cards, all I realised is how much I hate coding in Papyrus, You win I give up but as a parting gift my untested deck of cards code.. You and only I can use if any one else is pirate and a thief, I did not waste time with objects after all they are just strings, so I use string array, now you can all see my coding ))) and yeah I not print it, I could not be bothered, I just wanted it to end)))) ScriptName CardGame Extends Quest String Property HEARTS = "Hearts" AutoReadOnly String Property SPADES = "Spades" AutoReadOnly String Property CLUBS = "Clubs" AutoReadOnly String Property DIAMONDS = "Diamonds" AutoReadOnly String Property JACK = "Jack" AutoReadOnly String Property QUEEN = "Queen" AutoReadOnly String Property KING = "King" AutoReadOnly String Property ACE = "Ace" AutoReadOnly String Property OF = " Of " AutoReadOnly String[] rank String[] newCleanDeck Function CreateRank() if rank Return EndIf rank = new String[13] String[] pictures = new String[4] pictures[0] = JACK + OF pictures[1] = QUEEN + OF pictures[2] = KING + OF pictures[3] = ACE + OF int i = 2 While i < 13 if i < 11 rank[i] = i + OF Else rank[i] = pictures[i % 11] + OF EndIf i+=1 EndWhile EndFunction Function CreateNewCleanDeck() ; if newCleanDeck ; Return ; EndIf newCleanDeck = new String[52] String[] suites = new String[4] suites[0] = HEARTS suites[1] = SPADES suites[2] = CLUBS suites[3] = DIAMONDS int i = 0 int j = 0 While i < 52 newCleanDeck[i] = rank[i % 13]+ suites[j] i+=1 if i % 13 == 0 j+=1 EndIf EndWhile EndFunction Link to comment Share on other sites More sharing options...
PeterMartyr Posted May 24 Share Posted May 24 btw the way my brain was working is copy the new deck into a Shuffle Array with a capacity of 52, then generate a random number and move the card to stack array, consolidate the array so the end is empty with no spaces in the middle, with number of cards -= 1 then rinse and repeat with random number between 0 and number of cards left, move it, consolidate and repeat, until every single card is Shuffled randomly, with it all in the Stack. Once in the stack you simply deal off the top and it is any game you want to play from there. Depending of the game, if will OFC require who is the winner code)) btw once the Cards are Shuffled and the shuffle array is empty set the Shuffle Array to shuffle = new String[1] release the memory.... It was only a first draft and I am thinking of improvements, then I go stop you hate papyrus ))) but an organic first draught off the top of my head I think it's ok, hell I just say, shuffle from the new deck into the dealStack set the empty New Card to 1 element length , then on a new Game Allocate the new array to length of 52, I would try to release unused memory too It a Game releasing unused memory and avoiding creating unnecessary object to be dispose off is part of the deal. Link to comment Share on other sites More sharing options...
PeterMartyr Posted May 25 Share Posted May 25 @dylbill seriously this a gift for you, you can keep it ScriptName Deck Extends Quest String Property HEARTS = "Hearts" AutoReadOnly String Property SPADES = "Spades" AutoReadOnly String Property CLUBS = "Clubs" AutoReadOnly String Property DIAMONDS = "Diamonds" AutoReadOnly String Property JACK = "Jack" AutoReadOnly String Property QUEEN = "Queen" AutoReadOnly String Property KING = "King" AutoReadOnly String Property ACE = "Ace" AutoReadOnly String Property OF = " Of " AutoReadOnly String Property ScriptName_prop String Function Get() Return StringUtil.Split(StringUtil.Substring(Self, 1), StringUtil.AsChar(32))[0] EndFunction EndProperty String[] theDeck Int numberOfCards = 0 Function NewDeck() String[] rank rank = new String[13] String[] pictures = new String[4] pictures[0] = JACK pictures[1] = QUEEN pictures[2] = KING pictures[3] = ACE int i = 2 While i < 15 if i < 11 rank[i - 2] = i + OF Else rank[i - 2] = pictures[i % 11] + OF EndIf i+=1 EndWhile theDeck = new String[52] String[] suit = new String[4] suit[0] = HEARTS suit[1] = SPADES suit[2] = CLUBS suit[3] = DIAMONDS int j = 0 While j < suit.Length i = 0 While i < rank.Length theDeck[i] = rank[i]+ suit[j] numberOfCards+=1 EndWhile i+=1 EndWhile EndFunction Function Shuffle() int i = 0 Int random String temp While i < theDeck.Length random = Utility.RandomInt(0, theDeck.Length) temp = theDeck[i] theDeck[i] = theDeck[random] theDeck[random] = temp i+=1 EndWhile EndFunction String Function Deal() If !numberOfCards==0 numberOfCards -= 1 Return theDeck[numberOfCards] Else debug.MessageBox("no more cards") Return "no more cards" EndIf EndFunction Function ToUserTrace() Utility.SetINIBool("bEnableTrace:Papyrus", True) Debug.OpenUserLog(scriptName_prop) String objectName = StringUtil.Substring( StringUtil.Split(Self, StringUtil.AsChar(32))[1], 1) Debug.TraceUser(scriptName_prop, "==============================================================================") Debug.TraceUser(scriptName_prop, " ===== "+objectName+" As "+scriptName_prop+" =====") Debug.TraceUser(scriptName_prop, "==============================================================================") Debug.TraceUser(scriptName_prop, "Self: "+ Self) Debug.TraceUser(scriptName_prop, "Object Container: "+objectName) Debug.TraceUser(scriptName_prop, "Script Name: "+scriptName_prop) Debug.TraceUser(scriptName_prop, "Array Length: "+theDeck.Length) Int i = 0 While i < theDeck.Length Debug.TraceUser(scriptName_prop, " Index: ["+i+"], Element: "+theDeck[i]) i += 1 EndWhile Debug.TraceUser(scriptName_prop, "==============================================================================") Debug.TraceUser(scriptName_prop, "==============================================================================") Debug.CloseUserLog(scriptName_prop) Utility.SetINIBool("bEnableTrace:Papyrus", False) Debug.Notification("Custom Trace Logging Done") EndFunction I finished it.... Link to comment Share on other sites More sharing options...
dylbill Posted May 25 Share Posted May 25 Thanks, but I don't actually need card functions. The only reason I used PlayingCard was as an example of how you can add a new type / class to papyrus, which you're not doing in your script. Your script extends quest. And btw, I already wrote createDeck and randomizeDeck functions (that don't require skse). scriptname PlayingCard extends ObjectReference ;attach to a new misc object in the creation kit ObjectReference Property LinkedRef Auto string[] property suitStrings auto hidden string[] property facecardStrings auto hidden int property suit auto int property number auto Event OnInit() suitStrings = new string[4] suitStrings[0] = "CLUBS" suitStrings[1] = "DIAMONDS" suitStrings[2] = "HEARTS" suitStrings[3] = "SPADES" facecardStrings = new string[4] facecardStrings[0] = "ACE" facecardStrings[1] = "JACK" facecardStrings[2] = "QUEEN" facecardStrings[3] = "KING" EndEvent PlayingCard function Create(int iNumber, int iSuit, MiscObject playingCardMisc, objectReference placeAtMeRef = none, bool abForcePersist = false, bool abInitiallyDisabled = false) Global if !playingCardMisc return none endif if !placeAtMeRef placeAtMeRef = Game.GetPlayer() Endif if iNumber < 1 iNumber = 1 elseif iNumber > 13 iNumber = 13 Endif ObjectReference cardObj = placeAtMeRef.PlaceAtMe(playingCardMisc, 1, abForcePersist, abInitiallyDisabled) PlayingCard card = cardObj as PlayingCard if card card.Number = iNumber card.suit = iSuit return card Endif EndFunction playingCard[] function CreateDeck(MiscObject playingCardMisc, objectReference placeAtMeRef = none, bool abForcePersist = false, bool abInitiallyDisabled = false) Global if !placeAtMeRef placeAtMeRef = Game.GetPlayer() Endif if !playingCardMisc return none Endif playingCard[] deck = new playingCard[52] int deckIndex = 0 int suitIndex = 0 int numberIndex = 1 while numberIndex < 14 && deckIndex < 52 while suitIndex < 4 deck[deckIndex] = PlayingCard.Create(numberIndex, suitIndex, playingCardMisc, placeAtMeRef, abForcePersist, abInitiallyDisabled) suitIndex += 1 deckIndex += 1 EndWhile suitIndex = 0 numberIndex += 1 EndWhile return deck EndFunction playingCard function getRandomCard(playingCard[] deck) Global playingCard card int L = deck.length if L == 0 return card endif int r = Utility.RandomInt(0, L - 1) int i = r while !card && i < L card = deck[i] i += 1 EndWhile i = 0 while !card && i < R card = deck[i] i += 1 EndWhile return card EndFunction int function getRandomCardIndex(playingCard[] deck) Global playingCard card int randomIndex int L = deck.length if L == 0 return -1 endif int r = Utility.RandomInt(0, L - 1) int i = r while !card && i < L card = deck[i] i += 1 EndWhile if !card i = 0 while !card && i < R card = deck[i] i += 1 EndWhile endif return (i - 1) EndFunction playingCard[] function randomizeDeck(playingCard[] deck) Global playingCard[] randomizedDeck = new playingCard[52] int i = 0 int L = deck.Length while i < L int r = PlayingCard.getRandomCardIndex(deck) randomizedDeck[i] = deck[r] deck[r] = none i += 1 EndWhile return randomizedDeck EndFunction string function getSuitString() return suitStrings[suit] EndFunction string function getNumberString() if number >= 2 && number <= 10 return number as string elseif number == 1 return facecardStrings[0] else return facecardStrings[number - 10] endif EndFunction string function getFullCardString() string suitString = getSuitString() string numberString = getNumberString() return numberString + " OF " + suitString EndFunction Then in another script: MiscObject Property playingCardMisc Auto ;PlayingCard script is attached Event OnInit() Utility.wait(1) playingCard[] deckSorted = playingCard.CreateDeck(playingCardMisc, abInitiallyDisabled = true) playingCard[] deck = playingCard.randomizeDeck(deckSorted) string msg int i = 0 int L = deck.Length while i < L msg += (deck[i].getFullCardString() + "\n") i += 1 EndWhile ;my mod ExtendedVanillaMenus.MessageBox has a scroll feature ;msg would be too long for Debug.MessageBox() ExtendedVanillaMenus.MessageBox(msg) EndEvent Link to comment Share on other sites More sharing options...
Recommended Posts