archibalduk / TransferTool

An open source program to add and edit players using spreadsheets
2 stars 2 forks source link

NonPlayer Importer #15

Open edwjga85 opened 3 years ago

edwjga85 commented 3 years ago

I am a complete novice to coding but over the last few weeks have been experimenting with the code. I have since stumbled across a way of importing nonplayers and nonplayer attributes into the database.

Unfortunately, I can only import non players to a default job i.e. coach. For example if I was importing Roman Abramovich into the database, he would appear as a 'coach' and I would have to manually change him to 'Chairman'.

I have now hit a brick wall with trying to overcome this issue, everything I have tried has failed. I have experimented with the exporter option and can now export 'job roles' to a numeric value but cannot import using this method.

I am just wondering whether anyone with far more coding knowledge than myself could advise on how I would go about the next step of importing nonplayers to their correct 'job roles' and also converting the numeric value to the correct text?

Any help would be much appreciated!

MScientistCM commented 3 years ago

I am a complete novice to coding but over the last few weeks have been experimenting with the code. I have since stumbled across a way of importing nonplayers and nonplayer attributes into the database.

Unfortunately, I can only import non players to a default job i.e. coach. For example if I was importing Roman Abramovich into the database, he would appear as a 'coach' and I would have to manually change him to 'Chairman'.

I have now hit a brick wall with trying to overcome this issue, everything I have tried has failed. I have experimented with the exporter option and can now export 'job roles' to a numeric value but cannot import using this method.

I am just wondering whether anyone with far more coding knowledge than myself could advise on how I would go about the next step of importing nonplayers to their correct 'job roles' and also converting the numeric value to the correct text?

Any help would be much appreciated!

Nice effort.

You need to call this instruction when you import the staff, with the desired role, for example:

JobForClub.set(Job::COACH);

Or

JobForClub.set(Job::SCOUT);

Or

JobForClub.set(Job::PHYSIO);

etc

Let me know if that helps

edwjga85 commented 3 years ago

Thanks for responding!! Finally worked it out: Adding this line "staff->JobForClub.set(Job::ENUM_JOB(m_Spreadsheet->number(row, "name of column")));" sets to the correct job. However, at the moment this only works by setting a numeric value; for example if i want to set the job as a manager i would have to use the value "5" or if I am adding a chairman I would have to use the value "1". So the next challenge will be converting the ENUM value to string...

I am also thinking this should work for setting the playing squad (senior and reserve squads) and setting the staff classification but one step at a time!

In short I have a basic nonplayer importer that can import nonplayers into the database to their correct job.

MScientistCM commented 3 years ago

Thanks for responding!! Finally worked it out: Adding this line "staff->JobForClub.set(Job::ENUM_JOB(m_Spreadsheet->number(row, "name of column")));" sets to the correct job. However, at the moment this only works by setting a numeric value; for example if i want to set the job as a manager i would have to use the value "5" or if I am adding a chairman I would have to use the value "1". So the next challenge will be converting the ENUM value to string...

I am also thinking this should work for setting the playing squad (senior and reserve squads) and setting the staff classification but one step at a time!

In short I have a basic nonplayer importer that can import nonplayers into the database to their correct job.

nice job!

In my opinion using a numeric code for each job type is fine