7/5/2023 0 Comments Fminer randomly named element![]() You have some serious issues inside your genItem class. Read more about usage of different data structures in C++11. You need an easy access to elements by their index and in this case a std::vector would be a lot better (faster, easier to maintain and use). Usage of a list is an awful idea in this case.You don't add elements to list in a loop, so there's nothing surprising, that only one item displays. Tries to display random elements from list, but due to complicated condition inside getItem::Retreive, it always returns Head (it is the only element of the list anyway).Basing on rn and cat_item adds a single item to a list.Actually, this may be simply resolved by debugging your program - even manually, eg. General problemįirst of all, let's resolve your primary problem - displaying only one kind of item instead of several different ones. This is also a very localized problem, so I'll try to answer as broadly as possible, for this answer to be useful for more people than only you. Now you posted more source code, I'm able to get you more information, but this will be a long one. Strcpy_s(listItem -> itemName, "a destroying angel mushroom") Strcpy_s(listItem -> itemName, "a velvet shank mushroom") Strcpy_s(listItem -> itemName, "a bleeding milkcap mushroom") Strcpy_s(listItem -> itemName, "a shaggy inkcap mushroom") Strcpy_s(listItem -> itemName, "a mature deathcap mushroom") Strcpy_s(listItem -> itemName, "a poison pie mushroom") ![]() Strcpy_s(listItem -> itemName, "a fly agaric mushroom") Strcpy_s(listItem -> itemName, "a rotting jack o'lantern mushroom") Strcpy_s(listItem -> itemName, "a devil's bolete mushroom") Strcpy_s(listItem -> itemName, "an earthball mushroom") Void genItem::generate_item(int d2, int s2) genItem.hįor (int i = count() -1 i > position & current != NULL i-) I'm using a struct, a linked list, a class and pointers. I can get away with setting up a series of switch statements that will produce multiple search areas for a player to look through, thus getting a single new random item per area, but I'd like to learn how to deal with what I'm doing wrong here. The code will produce the same item multiple times. I'm trying to have an random number of items generate. The more difficult it is, the more specific each solution will be which can cause fragmentation between different custom element libraries that end up having very specific requirements for things like SSR to work properly.Īs an example of the opposite, the Declarative-Custom-Elements proposal would bring some standardization to custom elements as far as representation in HTML, which would make it easier to create things like SSR, and make it easier for custom element libraries to have a chance at being compatible with each other (there are still issues, the community would still need to make its own standards on top of that proposal, but the community standards would simpler and smaller).I'm experimenting with a game program. How would anonymous custom elements be represented in HTML? It seems this would make things like SSR (server-side rendering) more difficult to achieve. On the main topic, for what the OP is asking, I agree with that custom element registries scoped to ShadowDOM is a better approach for encapsulation of naming and implementation. It allows practically the same thing as custom elements (you write classes with the same life cycle methods), but allows you to have more than one of them associated with an element (which is convenient) without changing the original tag name of the element (for example apply them to or elements without breaking the DOM parser behavior like you otherwise do with custom elements that don't use the is="" approach which Safari does not want to implement for various valid reasons). That's a little tool I made which is basically an alternative to the is="" attribute (so basically an alternative to custom elements). :) That indeed could serve as an alternative in some cases but maybe not what the OP is asking for. I just saw this, it seems very interesting: I'm just observing that the need to register classes at all makes working with custom element classes more complex. But looking at other libraries on the web today that export classes, I can usually instantiate those classes immediately no other bookkeeping is required. In which the tag name is, at best, a side concern, it would be nicer to be able to just create the class and instantiate it.Īddressing this is clearly not essential - we can work around the problem. The main thing I'm trying to convey is that, over the past couple of years, I've come to realize that the number of situations in which I actually care about the tag name is small. ![]() define ( 'my-element', MyElement ) const myElement = new MyElement ( ) Class MyElement extends HTMLElement const myRegistry = new CustomElementRegistry ( window.
0 Comments
Leave a Reply. |