How much does this Integer score?

Mathematica, 63 bytes

s+Max@If[PrimeQ[s=Tr[d^Range@Length[d=IntegerDigits@#]]],d,-d]&

Pure function taking a positive integer as input and returning an integer. Directly performs the indicated computation, with all the long Mathematica command names that requires. Perhaps the one innovation is noticing that, if d is the list of digits of the input, then the last addition/subtraction is the same as adding Max[d] if the initial sum was prime, and adding Max[-d] if not.


05AB1E, 16 bytes

DpiZëW(}¹gL¹SmO+

Try it online!

Explanation

D                  # duplicate input
 piZ               # if input is prime then max digit of input
    ëW(            # else -min digit of input
       }           # end if
        ¹gL        # range [1 ... len(input)]
           ¹S      # input split into digits
             m     # pow
              O    # sum
               +   # add

Mathematica, 68 bytes

#+If[PrimeQ@#,Max@x,-Min@x]&@Tr[(x=IntegerDigits@#)^Range[Tr[1^x]]]&

Explanation

enter image description here

Sets x equal to the list of digits of the input, then raises that to the power Range[Tr[1^x]], effectively raising the first digit to the power 1, the second digit to the power 2, and so on up to Tr[1^x], the length of x. Tr sums the resulting list, which is then passed into the function #+If[PrimeQ@#,Max@x,-Min@x]&.